From 40c0f100a618f2b3e4dc668d219c3f7d65b659a5 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 14:45:29 +0900 Subject: [PATCH 01/86] Part 1 (doesn't compile yet) --- meson.build | 12 +- src/Application.vala | 33 +++-- src/MainWindow.vala | 179 +++++++++++++------------ src/Widgets/EditableLabel.vala | 35 +++-- src/Widgets/EntryPopover/DateTime.vala | 3 +- src/Widgets/EntryPopover/Generic.vala | 24 ++-- src/Widgets/EntryPopover/Location.vala | 1 - src/Widgets/ListSettingsPopover.vala | 121 ++++++++++------- src/Widgets/ScheduledTaskListGrid.vala | 3 - src/Widgets/TaskListGrid.vala | 3 - 10 files changed, 212 insertions(+), 202 deletions(-) diff --git a/meson.build b/meson.build index 22aafc0643..c5fa360f26 100644 --- a/meson.build +++ b/meson.build @@ -9,7 +9,7 @@ i18n = import('i18n') add_project_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c') add_project_arguments('-DLIBICAL_GLIB_UNSTABLE_API=1', language: 'c') - +add_project_arguments('-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED', language: 'c') gresource = gnome.compile_resources( 'gresource', join_paths('data', 'gresource.xml'), @@ -28,18 +28,14 @@ config_file = configure_file( libecal_dep = dependency('libecal-2.0') tasks_deps = [ - dependency('champlain-0.12'), - dependency('champlain-gtk-0.12'), - dependency('clutter-1.0'), - dependency('clutter-gtk-1.0'), dependency('glib-2.0'), dependency('gobject-2.0'), - dependency('granite', version: '>=6.2.0'), - dependency('gtk+-3.0'), + dependency('granite-7', version: '>=7.0.0'), + dependency('gtk4'), libecal_dep, dependency('libedataserver-1.2'), dependency('libgeoclue-2.0'), - dependency('libhandy-1', version: '>=0.90.0'), + # dependency('shumate-0-.0'), dependency('libical-glib') ] diff --git a/src/Application.vala b/src/Application.vala index 8603e0c463..aa8a3e4e8e 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -28,9 +28,9 @@ public class Tasks.Application : Gtk.Application { public static Tasks.TaskModel model; public static bool run_in_background = false; - public const Gtk.TargetEntry[] DRAG_AND_DROP_TASK_DATA = { - { "text/uri-list", Gtk.TargetFlags.SAME_APP | Gtk.TargetFlags.OTHER_WIDGET, 0 } // TODO: TEXT_URI - }; + // public Gtk.DropTarget[] DRAG_AND_DROP_TASK_DATA = { + // { "text/uri-list", Gtk.TargetFlags.SAME_APP | Gtk.TargetFlags.OTHER_WIDGET, 0 } // TODO: TEXT_URI + // }; public Application () { Object ( @@ -75,7 +75,7 @@ public class Tasks.Application : Gtk.Application { model.start.begin (); var main_window = new MainWindow (this); - add_window (main_window); + // add_window (main_window); int window_x, window_y; var rect = Gtk.Allocation (); @@ -83,11 +83,11 @@ public class Tasks.Application : Gtk.Application { settings.get ("window-position", "(ii)", out window_x, out window_y); settings.get ("window-size", "(ii)", out rect.width, out rect.height); - if (window_x != -1 || window_y != -1) { - main_window.move (window_x, window_y); - } + // if (window_x != -1 || window_y != -1) { + // main_window.move (window_x, window_y); + // } - main_window.set_allocation (rect); + // main_window.set_allocation (rect); if (settings.get_boolean ("window-maximized")) { main_window.maximize (); @@ -101,8 +101,6 @@ public class Tasks.Application : Gtk.Application { granite_settings.notify["prefers-color-scheme"].connect (() => { gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; }); - - main_window.show_all (); } active_window.present (); @@ -122,14 +120,14 @@ public class Tasks.Application : Gtk.Application { @define-color accent_color %s; """.printf (color, color); - try { - var style_provider = new Gtk.CssProvider (); - style_provider.load_from_data (style, style.length); + // try { + // var style_provider = new Gtk.CssProvider (); + // style_provider.load_from_data (style, style.length); - providers[color] = style_provider; - } catch (Error e) { - critical ("Unable to set color: %s", e.message); - } + // providers[color] = style_provider; + // } catch (Error e) { + // critical ("Unable to set color: %s", e.message); + // } } unowned Gtk.StyleContext style_context = widget.get_style_context (); @@ -137,7 +135,6 @@ public class Tasks.Application : Gtk.Application { } public static int main (string[] args) { - GtkClutter.init (ref args); var app = new Application (); int res = app.run (args); ICal.Object.free_global_objects (); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index c220c7a1cc..65fff2426c 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -18,7 +18,7 @@ * */ -public class Tasks.MainWindow : Hdy.ApplicationWindow { +public class Tasks.MainWindow : Gtk.ApplicationWindow { public const string ACTION_GROUP_PREFIX = "win"; public const string ACTION_PREFIX = ACTION_GROUP_PREFIX + "."; public const string ACTION_DELETE_SELECTED_LIST = "action-delete-selected-list"; @@ -36,7 +36,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { private Gee.HashMap? source_rows; private Gee.Collection? collection_sources; private Gtk.Stack task_list_grid_stack; - private Gtk.ButtonBox add_tasklist_buttonbox; + private Gtk.Box add_tasklist_buttonbox; public MainWindow (Gtk.Application application) { Object ( @@ -47,11 +47,9 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { } static construct { - Hdy.init (); - action_accelerators[ACTION_DELETE_SELECTED_LIST] = "BackSpace"; - Gtk.IconTheme.get_default ().add_resource_path ("/io/elementary/tasks"); + Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).add_resource_path ("/io/elementary/tasks"); } construct { @@ -64,48 +62,49 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { ); } - var sidebar_header = new Hdy.HeaderBar () { - has_subtitle = false, - show_close_button = true + var sidebar_header = new Gtk.HeaderBar () { + title_widget = new Gtk.Label (null), + show_title_buttons = true + // show_close_button = true }; unowned Gtk.StyleContext sidebar_header_context = sidebar_header.get_style_context (); sidebar_header_context.add_class ("default-decoration"); - sidebar_header_context.add_class (Gtk.STYLE_CLASS_FLAT); + sidebar_header_context.add_class (Granite.STYLE_CLASS_FLAT); - var main_header = new Hdy.HeaderBar () { - has_subtitle = false, - show_close_button = true + var main_header = new Gtk.HeaderBar () { + title_widget = new Gtk.Label (null), + show_title_buttons = true + // show_close_button = true }; // Create a header group that automatically assigns the right decoration controls to the // right headerbar automatically - var header_group = new Hdy.HeaderGroup (); - header_group.add_header_bar (sidebar_header); - header_group.add_header_bar (main_header); + var header_group = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + header_group.append (sidebar_header); + header_group.append (main_header); unowned Gtk.StyleContext main_header_context = main_header.get_style_context (); main_header_context.add_class ("default-decoration"); - main_header_context.add_class (Gtk.STYLE_CLASS_FLAT); + main_header_context.add_class (Granite.STYLE_CLASS_FLAT); listbox = new Gtk.ListBox (); listbox.set_sort_func (sort_function); var scheduled_row = new Tasks.Widgets.ScheduledRow (); - listbox.add (scheduled_row); + listbox.append (scheduled_row); - var scrolledwindow = new Gtk.ScrolledWindow (null, null) { - expand = true, - hscrollbar_policy = Gtk.PolicyType.NEVER + var scrolledwindow = new Gtk.ScrolledWindow () { + hexpand = true, + vexpand = true, + hscrollbar_policy = Gtk.PolicyType.NEVER, + child = listbox }; - scrolledwindow.add (listbox); - add_tasklist_buttonbox = new Gtk.ButtonBox (Gtk.Orientation.VERTICAL) { - layout_style = Gtk.ButtonBoxStyle.EXPAND - }; + add_tasklist_buttonbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); // TODO: check spacing - var online_accounts_button = new Gtk.ModelButton () { - text = _("Online Accounts Settings…") + var online_accounts_button = new Gtk.Button () { + label = _("Online Accounts Settings…") }; var add_tasklist_grid = new Gtk.Grid () { @@ -116,23 +115,23 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { add_tasklist_grid.attach (add_tasklist_buttonbox, 0, 0); add_tasklist_grid.attach (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 1); add_tasklist_grid.attach (online_accounts_button, 0, 2); - add_tasklist_grid.show_all (); - var add_tasklist_popover = new Gtk.Popover (null); - add_tasklist_popover.add (add_tasklist_grid); + var add_tasklist_popover = new Gtk.Popover () { + child = add_tasklist_grid + }; var add_tasklist_button = new Gtk.MenuButton () { label = _("Add Task List…"), - image = new Gtk.Image.from_icon_name ("list-add-symbolic", Gtk.IconSize.SMALL_TOOLBAR), - always_show_image = true, + icon_name = "list-add-symbolic", + // always_show_image = true, popover = add_tasklist_popover }; var actionbar = new Gtk.ActionBar (); - actionbar.add (add_tasklist_button); + actionbar.pack_start (add_tasklist_button); unowned Gtk.StyleContext actionbar_style_context = actionbar.get_style_context (); - actionbar_style_context.add_class (Gtk.STYLE_CLASS_FLAT); + actionbar_style_context.add_class (Granite.STYLE_CLASS_FLAT); var sidebar = new Gtk.Grid (); sidebar.attach (sidebar_header, 0, 0); @@ -140,20 +139,22 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { sidebar.attach (actionbar, 0, 2); unowned Gtk.StyleContext sidebar_style_context = sidebar.get_style_context (); - sidebar_style_context.add_class (Gtk.STYLE_CLASS_SIDEBAR); + sidebar_style_context.add_class (Granite.STYLE_CLASS_SIDEBAR); task_list_grid_stack = new Gtk.Stack (); var main_grid = new Gtk.Grid (); - main_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND); + main_grid.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); main_grid.attach (main_header, 0, 0); main_grid.attach (task_list_grid_stack, 0, 1); var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); - paned.pack1 (sidebar, false, false); - paned.pack2 (main_grid, true, false); + paned.start_child = sidebar; // (sidebar, false, false); + paned.end_child = main_grid; // (main_grid, true, false); + paned.resize_end_child = true; // ??? + - add (paned); + child = paned; online_accounts_button.clicked.connect (() => { try { @@ -304,8 +305,10 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { transient_for = this }; error_dialog.show_error_details (error_message); - error_dialog.run (); - error_dialog.destroy (); + error_dialog.present (); + error_dialog.response.connect (() => { + error_dialog.destroy (); + }); return GLib.Source.REMOVE; }); @@ -327,28 +330,30 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { }; unowned Gtk.Widget trash_button = message_dialog.add_button (_("Delete Anyway"), Gtk.ResponseType.YES); - trash_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); - - Gtk.ResponseType response = (Gtk.ResponseType) message_dialog.run (); - message_dialog.destroy (); - - if (response == Gtk.ResponseType.YES) { - Tasks.Application.model.remove_task_list.begin (source, (obj, res) => { - try { - Tasks.Application.model.remove_task_list.end (res); - } catch (Error e) { - critical (e.message); - show_error_dialog ( - _("Deleting the task list failed"), - _("The task list registry may be unavailable or unable to be written to."), - e - ); - } - }); - } + trash_button.get_style_context ().add_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); + + message_dialog.present (); + message_dialog.response.connect ((response_id) => { + var response = (Gtk.ResponseType) response_id; + if (response == Gtk.ResponseType.YES) { + Tasks.Application.model.remove_task_list.begin (source, (obj, res) => { + try { + Tasks.Application.model.remove_task_list.end (res); + } catch (Error e) { + critical (e.message); + show_error_dialog ( + _("Deleting the task list failed"), + _("The task list registry may be unavailable or unable to be written to."), + e + ); + } + }); + } + message_dialog.destroy (); + }); } else { - Gdk.beep (); + Gdk.Display.get_default ().beep (); } } @@ -366,7 +371,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { } var header_label = new Granite.HeaderLabel (Util.get_esource_collection_display_name (row.source)) { - ellipsize = Pango.EllipsizeMode.MIDDLE, + // ellipsize = Pango.EllipsizeMode.MIDDLE, margin_start = 6 }; @@ -400,8 +405,8 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { } collection_sources.add (collection_source); - var source_button = new Gtk.ModelButton () { - text = Util.get_esource_collection_display_name (collection_source), + var source_button = new Gtk.Button () { + label = Util.get_esource_collection_display_name (collection_source), sensitive = Application.model.is_add_task_list_supported (collection_source) }; @@ -409,8 +414,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { add_new_list (collection_source); }); - add_tasklist_buttonbox.add (source_button); - add_tasklist_buttonbox.show_all (); + add_tasklist_buttonbox.append (source_button); } private void add_source (E.Source source) { @@ -422,11 +426,10 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { if (!source_rows.has_key (source)) { source_rows[source] = new Tasks.Widgets.SourceRow (source); - listbox.add (source_rows[source]); + listbox.append (source_rows[source]); Idle.add (() => { listbox.invalidate_sort (); listbox.invalidate_headers (); - listbox.show_all (); return Source.REMOVE; }); @@ -472,31 +475,31 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow { }); } - public override bool configure_event (Gdk.EventConfigure event) { - if (configure_id != 0) { - GLib.Source.remove (configure_id); - } + // public override bool configure_event (Gdk.EventConfigure event) { + // if (configure_id != 0) { + // GLib.Source.remove (configure_id); + // } - configure_id = Timeout.add (100, () => { - configure_id = 0; + // configure_id = Timeout.add (100, () => { + // configure_id = 0; - if (is_maximized) { - Tasks.Application.settings.set_boolean ("window-maximized", true); - } else { - Tasks.Application.settings.set_boolean ("window-maximized", false); + // if (is_maximized) { + // Tasks.Application.settings.set_boolean ("window-maximized", true); + // } else { + // Tasks.Application.settings.set_boolean ("window-maximized", false); - Gdk.Rectangle rect; - get_allocation (out rect); - Tasks.Application.settings.set ("window-size", "(ii)", rect.width, rect.height); + // Gdk.Rectangle rect; + // get_allocation (out rect); + // Tasks.Application.settings.set ("window-size", "(ii)", rect.width, rect.height); - int root_x, root_y; - get_position (out root_x, out root_y); - Tasks.Application.settings.set ("window-position", "(ii)", root_x, root_y); - } + // int root_x, root_y; + // get_position (out root_x, out root_y); + // Tasks.Application.settings.set ("window-position", "(ii)", root_x, root_y); + // } - return false; - }); + // return false; + // }); - return base.configure_event (event); - } + // return base.configure_event (event); + // } } diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index c3eea22939..bc45639a8b 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -19,7 +19,7 @@ * Authored by: Corentin Noël */ -public class Tasks.Widgets.EditableLabel : Gtk.EventBox { +public class Tasks.Widgets.EditableLabel : Gtk.Widget { public signal void changed (); private static Gtk.CssProvider label_provider; @@ -27,7 +27,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { private Gtk.Label title; private Gtk.Entry entry; private Gtk.Stack stack; - private Gtk.Grid grid; + private Gtk.Box box; public string text { get; set; } @@ -44,7 +44,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { changed (); } - stack.set_visible_child (grid); + stack.set_visible_child (box); } } } @@ -60,9 +60,9 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { style_context.add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); valign = Gtk.Align.CENTER; - events |= Gdk.EventMask.ENTER_NOTIFY_MASK; - events |= Gdk.EventMask.LEAVE_NOTIFY_MASK; - events |= Gdk.EventMask.BUTTON_PRESS_MASK; + // events |= Gdk.EventMask.ENTER_NOTIFY_MASK; + // events |= Gdk.EventMask.LEAVE_NOTIFY_MASK; + // events |= Gdk.EventMask.BUTTON_PRESS_MASK; title = new Gtk.Label ("") { ellipsize = Pango.EllipsizeMode.END, @@ -70,23 +70,22 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { }; var edit_button = new Gtk.Button () { - image = new Gtk.Image.from_icon_name ("edit-symbolic", Gtk.IconSize.MENU), + icon_name = "edit-symbolic", tooltip_text = _("Edit…") }; - edit_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + edit_button.get_style_context ().add_class (Granite.STYLE_CLASS_FLAT); var button_revealer = new Gtk.Revealer () { valign = Gtk.Align.CENTER, - transition_type = Gtk.RevealerTransitionType.CROSSFADE + transition_type = Gtk.RevealerTransitionType.CROSSFADE, + child = edit_button }; - button_revealer.add (edit_button); - grid = new Gtk.Grid () { - valign = Gtk.Align.CENTER, - column_spacing = 12 + box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12) { + valign = Gtk.Align.CENTER }; - grid.add (title); - grid.add (button_revealer); + box.append (title); + box.append (button_revealer); entry = new Gtk.Entry () { hexpand = true @@ -97,10 +96,10 @@ public class Tasks.Widgets.EditableLabel : Gtk.EventBox { hhomogeneous = false, transition_type = Gtk.StackTransitionType.CROSSFADE }; - stack.add (grid); - stack.add (entry); + stack.add_child (box); + stack.add_child (entry); - add (stack); + stack.set_parent (this); // ? bind_property ("text", title, "label"); diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index 6b9a9012b5..338718e2ed 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -19,7 +19,7 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { private Gtk.Calendar calendar; - private Granite.Widgets.TimePicker timepicker; + private Granite.TimePicker timepicker; private Gtk.Revealer timepicker_revealer; public DateTime () { @@ -63,7 +63,6 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { grid.attach (today_separator, 0, 1); grid.attach (calendar, 0, 2); grid.attach (timepicker_revealer, 0, 3); - grid.show_all (); popover.add (grid); diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 06740be456..90f8684c38 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -17,7 +17,7 @@ * Boston, MA 02110-1301 USA */ -public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.EventBox { +public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { public signal string? value_format (T value); public signal void value_changed (T value); @@ -55,34 +55,34 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.EventBox { popover_button = new Gtk.MenuButton () { label = placeholder, popover = popover, - image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.BUTTON), - always_show_image = icon_name != null + icon_name = icon_name, + // always_show_image = icon_name != null }; unowned Gtk.StyleContext popover_button_context = popover_button.get_style_context (); - popover_button_context.add_class (Gtk.STYLE_CLASS_FLAT); + popover_button_context.add_class (Granite.STYLE_CLASS_FLAT); popover_button_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic", Gtk.IconSize.BUTTON) { + var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic") { tooltip_text = _("Remove") }; unowned Gtk.StyleContext delete_button_context = delete_button.get_style_context (); - delete_button_context.add_class (Gtk.STYLE_CLASS_FLAT); + delete_button_context.add_class (Granite.STYLE_CLASS_FLAT); delete_button_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var delete_button_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT, - reveal_child = false + reveal_child = false, + child = delete_button }; - delete_button_revealer.add (delete_button); - var button_box = new Gtk.Grid (); - button_box.add (popover_button); - button_box.add (delete_button_revealer); + var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + button_box.append (popover_button); + button_box.append (delete_button_revealer); button_box.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - add (button_box); + button_box.set_parent (this); // ? delete_button.clicked.connect (() => { var value_has_changed = value != null; diff --git a/src/Widgets/EntryPopover/Location.vala b/src/Widgets/EntryPopover/Location.vala index e24bed151f..8eaecc3c22 100644 --- a/src/Widgets/EntryPopover/Location.vala +++ b/src/Widgets/EntryPopover/Location.vala @@ -69,7 +69,6 @@ public class Tasks.Widgets.EntryPopover.Location : Generic { grid.attach (search_entry, 0, 0); grid.attach (location_mode, 0, 1); grid.attach (map_frame, 0, 2); - grid.show_all (); popover.add (grid); popover.show.connect (on_popover_show); diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index 04ce2e39a4..bc97d35d80 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -21,95 +21,117 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { public E.Source source { get; set; } - private Gtk.RadioButton color_button_red; - private Gtk.RadioButton color_button_orange; - private Gtk.RadioButton color_button_yellow; - private Gtk.RadioButton color_button_green; - private Gtk.RadioButton color_button_mint; - private Gtk.RadioButton color_button_blue; - private Gtk.RadioButton color_button_purple; - private Gtk.RadioButton color_button_pink; - private Gtk.RadioButton color_button_brown; - private Gtk.RadioButton color_button_slate; - private Gtk.RadioButton color_button_none; + private Gtk.CheckButton color_button_red; + private Gtk.CheckButton color_button_orange; + private Gtk.CheckButton color_button_yellow; + private Gtk.CheckButton color_button_green; + private Gtk.CheckButton color_button_mint; + private Gtk.CheckButton color_button_blue; + private Gtk.CheckButton color_button_purple; + private Gtk.CheckButton color_button_pink; + private Gtk.CheckButton color_button_brown; + private Gtk.CheckButton color_button_slate; + private Gtk.CheckButton color_button_none; construct { - color_button_blue = new Gtk.RadioButton (null); + color_button_blue = new Gtk.CheckButton (); unowned Gtk.StyleContext color_button_blue_context = color_button_blue.get_style_context (); color_button_blue_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_blue_context.add_class ("blue"); - color_button_mint = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_mint = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_mint_context = color_button_mint.get_style_context (); color_button_mint_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_mint_context.add_class ("mint"); - color_button_green = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_green = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_green_context = color_button_green.get_style_context (); color_button_green_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_green_context.add_class ("green"); - color_button_yellow = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_yellow = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_yellow_context = color_button_yellow.get_style_context (); color_button_yellow_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_yellow_context.add_class ("yellow"); - color_button_orange = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_orange = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_orange_context = color_button_orange.get_style_context (); color_button_orange_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_orange_context.add_class ("orange"); - color_button_red = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_red = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_red_context = color_button_red.get_style_context (); color_button_red_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_red_context.add_class ("red"); - color_button_pink = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_pink = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_pink_context = color_button_pink.get_style_context (); color_button_pink_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_pink_context.add_class ("pink"); - color_button_purple = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_purple = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_purple_context = color_button_purple.get_style_context (); color_button_purple_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_purple_context.add_class ("purple"); - color_button_brown = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_brown = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_brown_context = color_button_brown.get_style_context (); color_button_brown_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_brown_context.add_class ("brown"); - color_button_slate = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_slate = new Gtk.CheckButton () { + group = color_button_blue + }; unowned Gtk.StyleContext color_button_slate_context = color_button_slate.get_style_context (); color_button_slate_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); color_button_slate_context.add_class ("slate"); - color_button_none = new Gtk.RadioButton.from_widget (color_button_blue); + color_button_none = new Gtk.CheckButton () { + group = color_button_blue + }; - var color_grid = new Gtk.Grid () { - column_spacing = 6, - margin = 12 + var color_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { + margin_top = 12, + margin_bottom = 12, + margin_start = 12, + margin_end = 12, }; - color_grid.add (color_button_blue); - color_grid.add (color_button_mint); - color_grid.add (color_button_green); - color_grid.add (color_button_yellow); - color_grid.add (color_button_orange); - color_grid.add (color_button_red); - color_grid.add (color_button_pink); - color_grid.add (color_button_purple); - color_grid.add (color_button_brown); - color_grid.add (color_button_slate); + color_box.append (color_button_blue); + color_box.append (color_button_mint); + color_box.append (color_button_green); + color_box.append (color_button_yellow); + color_box.append (color_button_orange); + color_box.append (color_button_red); + color_box.append (color_button_pink); + color_box.append (color_button_purple); + color_box.append (color_button_brown); + color_box.append (color_button_slate); var show_completed_button = new Granite.SwitchModelButton (_("Show Completed")) { margin_top = 3 @@ -120,23 +142,22 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { MainWindow.ACTION_PREFIX + MainWindow.ACTION_DELETE_SELECTED_LIST ); - var delete_list_menuitem = new Gtk.ModelButton (); + var delete_list_menuitem = new Gtk.Button (); delete_list_menuitem.action_name = delete_list_accel_label.action_name; delete_list_menuitem.get_child ().destroy (); - delete_list_menuitem.add (delete_list_accel_label); - delete_list_menuitem.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); + delete_list_menuitem.child = delete_list_accel_label; + delete_list_menuitem.get_style_context ().add_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); - var grid = new Gtk.Grid () { - orientation = Gtk.Orientation.VERTICAL, - margin_top = margin_bottom = 3 + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { + margin_top = 3, + margin_bottom = 3 }; - grid.add (color_grid); - grid.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); - grid.add (show_completed_button); - grid.add (delete_list_menuitem); - grid.show_all (); + box.append (color_box); + box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); + box.append (show_completed_button); + box.append (delete_list_menuitem); - add (grid); + child = box; color_button_red.toggled.connect (() => { if (color_button_red.active) { @@ -277,7 +298,9 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { Gtk.ButtonsType.CLOSE ); error_dialog.show_error_details (e.message); - error_dialog.run (); - error_dialog.destroy (); + error_dialog.present (); + error_dialog.response.connect (() => { + error_dialog.destroy (); + }); } } diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index 053f1094f6..919a87b548 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -112,8 +112,6 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { task_list.row_activated.connect (on_row_activated); - show_all (); - model.task_list_added.connect (add_task_list); model.task_list_modified.connect (modify_task_list); model.task_list_removed.connect (remove_task_list); @@ -283,7 +281,6 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { Idle.add (() => { task_list.invalidate_sort (); - task_list.show_all (); return Source.REMOVE; }); diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 944a9d6d7d..305e10453e 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -186,8 +186,6 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }); }); }); - - show_all (); } private void on_show_completed_changed (bool show_completed) { @@ -371,7 +369,6 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { Idle.add (() => { task_list.invalidate_sort (); - task_list.show_all (); return Source.REMOVE; }); From 7ea7f1049141fac498e871b503f8fc7a2b5b72f1 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 20:00:45 +0900 Subject: [PATCH 02/86] It compiles! --- data/gschema.xml | 16 +- meson.build | 2 +- src/Application.vala | 29 +-- src/MainWindow.vala | 45 ++-- src/TaskModel.vala | 3 +- src/Widgets/EditableLabel.vala | 44 ++-- src/Widgets/EntryPopover/DateTime.vala | 51 ++-- src/Widgets/EntryPopover/Generic.vala | 14 +- src/Widgets/EntryPopover/Location.vala | 16 +- src/Widgets/ScheduledRow.vala | 11 +- src/Widgets/ScheduledTaskListGrid.vala | 132 +++++----- src/Widgets/SourceRow.vala | 231 +++++++++--------- src/Widgets/TaskListGrid.vala | 280 +++++++++++---------- src/Widgets/TaskRow.vala | 326 +++++++++++++------------ 14 files changed, 590 insertions(+), 610 deletions(-) diff --git a/data/gschema.xml b/data/gschema.xml index 67160844ce..4696940294 100644 --- a/data/gschema.xml +++ b/data/gschema.xml @@ -6,15 +6,15 @@ Whether the window was maximized on last run Whether the window was maximized on last run - - (-1, -1) - Window position - Most recent window position (x, y) + + 1024 + Most recent window width + Most recent window width - - (1000, 800) - Most recent window size - Most recent window size (width, height) + + 750 + Most recent window height + Most recent window height 256 diff --git a/meson.build b/meson.build index c5fa360f26..338d93451f 100644 --- a/meson.build +++ b/meson.build @@ -65,7 +65,7 @@ executable( 'src/Widgets/EditableLabel.vala', 'src/Widgets/EntryPopover/DateTime.vala', 'src/Widgets/EntryPopover/Generic.vala', - 'src/Widgets/EntryPopover/Location.vala', + # 'src/Widgets/EntryPopover/Location.vala', 'src/Widgets/ScheduledRow.vala', 'src/Widgets/SourceRow.vala', 'src/Widgets/ScheduledTaskListGrid.vala', diff --git a/src/Application.vala b/src/Application.vala index aa8a3e4e8e..e7ee3f9e00 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -75,23 +75,7 @@ public class Tasks.Application : Gtk.Application { model.start.begin (); var main_window = new MainWindow (this); - // add_window (main_window); - - int window_x, window_y; - var rect = Gtk.Allocation (); - - settings.get ("window-position", "(ii)", out window_x, out window_y); - settings.get ("window-size", "(ii)", out rect.width, out rect.height); - - // if (window_x != -1 || window_y != -1) { - // main_window.move (window_x, window_y); - // } - - // main_window.set_allocation (rect); - - if (settings.get_boolean ("window-maximized")) { - main_window.maximize (); - } + add_window (main_window); var granite_settings = Granite.Settings.get_default (); var gtk_settings = Gtk.Settings.get_default (); @@ -104,6 +88,7 @@ public class Tasks.Application : Gtk.Application { } active_window.present (); + warning ("Presented"); } private static Gee.HashMap? providers; @@ -120,14 +105,10 @@ public class Tasks.Application : Gtk.Application { @define-color accent_color %s; """.printf (color, color); - // try { - // var style_provider = new Gtk.CssProvider (); - // style_provider.load_from_data (style, style.length); + var style_provider = new Gtk.CssProvider (); + style_provider.load_from_data ((uint8[])style); - // providers[color] = style_provider; - // } catch (Error e) { - // critical ("Unable to set color: %s", e.message); - // } + providers[color] = style_provider; } unowned Gtk.StyleContext style_context = widget.get_style_context (); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 65fff2426c..2fdb1c7674 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -65,7 +65,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var sidebar_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), show_title_buttons = true - // show_close_button = true }; unowned Gtk.StyleContext sidebar_header_context = sidebar_header.get_style_context (); @@ -75,15 +74,8 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var main_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), show_title_buttons = true - // show_close_button = true }; - // Create a header group that automatically assigns the right decoration controls to the - // right headerbar automatically - var header_group = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - header_group.append (sidebar_header); - header_group.append (main_header); - unowned Gtk.StyleContext main_header_context = main_header.get_style_context (); main_header_context.add_class ("default-decoration"); main_header_context.add_class (Granite.STYLE_CLASS_FLAT); @@ -107,17 +99,16 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { label = _("Online Accounts Settings…") }; - var add_tasklist_grid = new Gtk.Grid () { + var add_tasklist_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3) { margin_top = 3, - margin_bottom = 3, - row_spacing = 3 + margin_bottom = 3 }; - add_tasklist_grid.attach (add_tasklist_buttonbox, 0, 0); - add_tasklist_grid.attach (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 1); - add_tasklist_grid.attach (online_accounts_button, 0, 2); + add_tasklist_box.append (add_tasklist_buttonbox); + add_tasklist_box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); + add_tasklist_box.append (online_accounts_button); var add_tasklist_popover = new Gtk.Popover () { - child = add_tasklist_grid + child = add_tasklist_box }; var add_tasklist_button = new Gtk.MenuButton () { @@ -133,29 +124,33 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { unowned Gtk.StyleContext actionbar_style_context = actionbar.get_style_context (); actionbar_style_context.add_class (Granite.STYLE_CLASS_FLAT); - var sidebar = new Gtk.Grid (); - sidebar.attach (sidebar_header, 0, 0); - sidebar.attach (scrolledwindow, 0, 1); - sidebar.attach (actionbar, 0, 2); + var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + sidebar.append (sidebar_header); + sidebar.append (scrolledwindow); + sidebar.append (actionbar); unowned Gtk.StyleContext sidebar_style_context = sidebar.get_style_context (); sidebar_style_context.add_class (Granite.STYLE_CLASS_SIDEBAR); task_list_grid_stack = new Gtk.Stack (); - var main_grid = new Gtk.Grid (); - main_grid.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); - main_grid.attach (main_header, 0, 0); - main_grid.attach (task_list_grid_stack, 0, 1); + var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + main_box.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); + main_box.append (main_header); + main_box.append (task_list_grid_stack); var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); paned.start_child = sidebar; // (sidebar, false, false); - paned.end_child = main_grid; // (main_grid, true, false); + paned.end_child = main_box; // (main_box, true, false); paned.resize_end_child = true; // ??? - child = paned; + var settings = new GLib.Settings ("io.elementary.tasks"); + settings.bind ("window-width", this, "default-width", SettingsBindFlags.DEFAULT); + settings.bind ("window-height", this, "default-height", SettingsBindFlags.DEFAULT); + settings.bind ("window-maximized", this, "maximized", SettingsBindFlags.DEFAULT); + online_accounts_button.clicked.connect (() => { try { AppInfo.launch_default_for_uri ("settings://accounts/online", null); diff --git a/src/TaskModel.vala b/src/TaskModel.vala index 0973e4c8ad..41e619ebe8 100644 --- a/src/TaskModel.vala +++ b/src/TaskModel.vala @@ -133,7 +133,8 @@ public class Tasks.TaskModel : Object { construct { task_list_client = new HashTable (str_hash, str_equal); task_list_client_views = new HashTable> (direct_hash, direct_equal); // vala-lint=line-length - network_monitor = NetworkMonitor.get_default (); + // Failed to initialize portal (GNetworkMonitorPortal) for gio-network-monitor: Not using portals + // network_monitor = NetworkMonitor.get_default (); } public async void start () { diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index bc45639a8b..c235b9f835 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -60,9 +60,15 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { style_context.add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); valign = Gtk.Align.CENTER; - // events |= Gdk.EventMask.ENTER_NOTIFY_MASK; - // events |= Gdk.EventMask.LEAVE_NOTIFY_MASK; - // events |= Gdk.EventMask.BUTTON_PRESS_MASK; + + var motion_controller = new Gtk.EventControllerMotion (); + add_controller (motion_controller); + + var press_controller = new Gtk.GestureClick (); + add_controller (press_controller); + + var focus_controller = new Gtk.EventControllerFocus (); + entry.add_controller (focus_controller); title = new Gtk.Label ("") { ellipsize = Pango.EllipsizeMode.END, @@ -103,25 +109,16 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { bind_property ("text", title, "label"); - enter_notify_event.connect ((event) => { - if (event.detail != Gdk.NotifyType.INFERIOR) { - button_revealer.reveal_child = true; - } - - return Gdk.EVENT_PROPAGATE; + motion_controller.enter.connect ((x, y) => { + button_revealer.reveal_child = true; }); - leave_notify_event.connect ((event) => { - if (event.detail != Gdk.NotifyType.INFERIOR) { - button_revealer.reveal_child = false; - } - - return Gdk.EVENT_PROPAGATE; + motion_controller.leave.connect (() => { + button_revealer.reveal_child = false; }); - button_press_event.connect ((event) => { + press_controller.pressed.connect ((n_press, x, y) => { editing = true; - return Gdk.EVENT_PROPAGATE; }); edit_button.clicked.connect (() => { @@ -134,15 +131,16 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { } }); - grab_focus.connect (() => { - editing = true; - }); - - entry.focus_out_event.connect ((event) => { + focus_controller.leave.connect (() => { if (stack.visible_child == entry) { editing = false; } - return Gdk.EVENT_PROPAGATE; }); } + + public override bool grab_focus () { + editing = true; + + return Gdk.EVENT_STOP; + } } diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index 338718e2ed..e3c41ca7e7 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -31,44 +31,47 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { construct { calendar = new Gtk.Calendar () { - margin = 6 + margin_top = 6, + margin_bottom = 6, + margin_start = 6, + margin_end = 6 }; - calendar.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND); + calendar.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); - timepicker = new Granite.Widgets.TimePicker () { - margin = 12, - margin_top = 0 + timepicker = new Granite.TimePicker () { + margin_top = 12, + margin_bottom = 12, + margin_start = 12, + margin_end = 12 }; timepicker_revealer = new Gtk.Revealer () { reveal_child = true, - margin = 0 + child = timepicker }; - timepicker_revealer.add (timepicker); - var today_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { margin_bottom = 3, margin_top = 3 }; - var today_button = new Gtk.ModelButton () { - text = _("Today") + var today_button = new Gtk.Button () { + label = _("Today") }; - var grid = new Gtk.Grid () { + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top= 3 }; - grid.attach (today_button, 0, 0); - grid.attach (today_separator, 0, 1); - grid.attach (calendar, 0, 2); - grid.attach (timepicker_revealer, 0, 3); + box.append (today_button); + box.append (today_separator); + box.append (calendar); + box.append (timepicker_revealer); - popover.add (grid); + popover.child = box; popover.show.connect (on_popover_show); - today_button.button_release_event.connect (on_today_button_release_event); + today_button.clicked.connect (on_today_button_clicked); calendar.day_selected.connect (on_calendar_day_selected); timepicker.time_changed.connect (on_timepicker_time_changed); } @@ -86,18 +89,18 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { value = selected_datetime; } - calendar.select_month (selected_datetime.get_month () - 1, selected_datetime.get_year ()); - calendar.select_day (selected_datetime.get_day_of_month ()); + calendar.select_day (selected_datetime); + // calendar.select_month (selected_datetime.get_month () - 1, selected_datetime.get_year ()); + // calendar.select_day (selected_datetime.get_day_of_month ()); timepicker.time = selected_datetime; } - private bool on_today_button_release_event () { + private void on_today_button_clicked () { var now_local = new GLib.DateTime.now_local (); - calendar.select_month (now_local.get_month () - 1, now_local.get_year ()); - calendar.select_day (now_local.get_day_of_month ()); - - return Gdk.EVENT_STOP; + calendar.select_day (now_local); + // calendar.select_month (now_local.get_month () - 1, now_local.get_year ()); + // calendar.select_day (now_local.get_day_of_month ()); } private void on_calendar_day_selected () { diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 90f8684c38..0f273c73a3 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -47,10 +47,12 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { } construct { - events |= Gdk.EventMask.ENTER_NOTIFY_MASK - | Gdk.EventMask.LEAVE_NOTIFY_MASK; + var motion_controller = new Gtk.EventControllerMotion (); + add_controller (motion_controller); - popover = new Gtk.Popover (popover_button); + popover = new Gtk.Popover () { + child = popover_button + }; popover_button = new Gtk.MenuButton () { label = placeholder, @@ -92,7 +94,7 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { } }); - popover_button.clicked.connect (() => { + popover_button.activate.connect (() => { if (delete_button_revealer.reveal_child) { delete_button_revealer.reveal_child = false; } @@ -112,13 +114,13 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { } }); - enter_notify_event.connect (() => { + motion_controller.enter.connect ((x, y) => { if (value_format (value) != null) { delete_button_revealer.reveal_child = true; } }); - leave_notify_event.connect (() => { + motion_controller.leave.connect (() => { if (delete_button_revealer.reveal_child) { delete_button_revealer.reveal_child = false; } diff --git a/src/Widgets/EntryPopover/Location.vala b/src/Widgets/EntryPopover/Location.vala index 8eaecc3c22..343c3e646e 100644 --- a/src/Widgets/EntryPopover/Location.vala +++ b/src/Widgets/EntryPopover/Location.vala @@ -61,16 +61,18 @@ public class Tasks.Widgets.EntryPopover.Location : Generic { hexpand = true }; - var grid = new Gtk.Grid () { - margin = 12, - row_spacing = 12 + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) { + margin_top = 12, + margin_bottom = 12, + margin_start = 12, + margin_end = 12 }; - grid.attach (search_entry, 0, 0); - grid.attach (location_mode, 0, 1); - grid.attach (map_frame, 0, 2); + box.append (search_entry); + box.append (location_mode); + box.append (map_frame); - popover.add (grid); + popover.add (box); popover.show.connect (on_popover_show); notify["value"].connect (on_value_changed); diff --git a/src/Widgets/ScheduledRow.vala b/src/Widgets/ScheduledRow.vala index 3c79403f48..1ee245b19e 100644 --- a/src/Widgets/ScheduledRow.vala +++ b/src/Widgets/ScheduledRow.vala @@ -21,7 +21,7 @@ public class Tasks.Widgets.ScheduledRow : Gtk.ListBoxRow { construct { - var icon = new Gtk.Image.from_icon_name ("appointment", Gtk.IconSize.MENU); + var icon = new Gtk.Image.from_icon_name ("appointment"); var display_name_label = new Gtk.Label (_("Scheduled")) { ellipsize = Pango.EllipsizeMode.MIDDLE, @@ -30,14 +30,13 @@ public class Tasks.Widgets.ScheduledRow : Gtk.ListBoxRow { margin_end = 9 }; - var grid = new Gtk.Grid () { - column_spacing = 6, + var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { margin_start = 12, margin_end = 6 }; - grid.add (icon); - grid.add (display_name_label); + box.append (icon); + box.append (display_name_label); - add (grid); + child = box; } } diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index 919a87b548..27e5afd27b 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -18,7 +18,7 @@ * */ -public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { +public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { private Gee.Map views; private const string QUERY = "AND (NOT is-completed?) (has-start?)"; @@ -48,10 +48,13 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { } private void remove_view (E.Source source) { - foreach (unowned Gtk.Widget child in get_children ()) { + unowned var child = get_first_child (); + while (child != null) { if (child is Tasks.Widgets.TaskRow && ((Tasks.Widgets.TaskRow) child).source == source) { child.destroy (); } + + child = child.get_next_sibling (); } lock (views) { @@ -88,7 +91,7 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { placeholder.show (); unowned Gtk.StyleContext placeholder_context = placeholder.get_style_context (); - placeholder_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); + placeholder_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); placeholder_context.add_class (Granite.STYLE_CLASS_H2_LABEL); task_list = new Gtk.ListBox () { @@ -98,17 +101,19 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { task_list.set_placeholder (placeholder); task_list.set_sort_func (sort_function); task_list.set_header_func (header_function); - task_list.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND); + task_list.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); - var scrolled_window = new Gtk.ScrolledWindow (null, null) { - expand = true, - hscrollbar_policy = Gtk.PolicyType.NEVER + var scrolled_window = new Gtk.ScrolledWindow () { + hexpand = true, + vexpand = true, + hscrollbar_policy = Gtk.PolicyType.NEVER, + child = task_list }; - scrolled_window.add (task_list); - column_spacing = 12; - attach (scheduled_title, 0, 0); - attach (scrolled_window, 0, 1); + orientation = Gtk.Orientation.VERTICAL; + spacing = 12; + append (scheduled_title); + append (scrolled_window); task_list.row_activated.connect (on_row_activated); @@ -156,10 +161,11 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { var task_row = (Tasks.Widgets.TaskRow) row; task_row.reveal_child_request (true); - unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - if (win_action_map != null) { - ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); - } + // ((Gtk.Window) get_root ()).get_application ().lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST).set_enabled (false); + // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); + // if (win_action_map != null) { + // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + // } } private void on_row_unselect (Gtk.ListBoxRow row) { @@ -196,9 +202,9 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { } } - var due_date_time = Util.ical_to_date_time_local (comp.get_due ()); + var due_date_time = Tasks.Util.ical_to_date_time_local (comp.get_due ()); var header_label = new Granite.HeaderLabel (Tasks.Util.get_relative_date (due_date_time)); - header_label.ellipsize = Pango.EllipsizeMode.MIDDLE; + // header_label.ellipsize = Pango.EllipsizeMode.MIDDLE; header_label.margin_start = 6; row.set_header (header_label); @@ -211,70 +217,64 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Grid { task_row.task_completed.connect ((task) => { Tasks.Application.model.complete_task.begin (source, task, (obj, res) => { - GLib.Idle.add (() => { - try { - Tasks.Application.model.complete_task.end (res); - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Completing task failed"), - _("The task registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Tasks.Application.model.complete_task.end (res); + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Completing task failed"), + _("The task registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); task_row.task_changed.connect ((task) => { Tasks.Application.model.update_task.begin (source, task, ECal.ObjModType.THIS_AND_FUTURE, (obj, res) => { - GLib.Idle.add (() => { - try { - Tasks.Application.model.update_task.end (res); - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Updating task failed"), - _("The task registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Tasks.Application.model.update_task.end (res); + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Updating task failed"), + _("The task registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); task_row.task_removed.connect ((task) => { Tasks.Application.model.remove_task.begin (source, task, ECal.ObjModType.ALL, (obj, res) => { - GLib.Idle.add (() => { - try { - Tasks.Application.model.remove_task.end (res); - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Removing task failed"), - _("The task registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Tasks.Application.model.remove_task.end (res); + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Removing task failed"), + _("The task registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); - task_list.add (task_row); + task_list.append (task_row); return true; }); diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 889377db94..6b3334195c 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -59,7 +59,7 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { status_image.get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var spinner = new Gtk.Spinner () { - active = true, + spinning = true, tooltip_text = _("Connecting…") }; @@ -67,134 +67,133 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { status_stack.add_named (status_image, "image"); status_stack.add_named (spinner, "spinner"); - var grid = new Gtk.Grid () { - column_spacing = 6, + var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { margin_start = 12, margin_end = 6 }; - grid.add (source_color); - grid.add (display_name_label); - grid.add (status_stack); + box.append (source_color); + box.append (display_name_label); + box.append (status_stack); revealer = new Gtk.Revealer () { - reveal_child = true + reveal_child = true, + child = box }; - revealer.add (grid); - add (revealer); + child = revealer; get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - build_drag_and_drop (); + // build_drag_and_drop (); update_request (); } - private void build_drag_and_drop () { - Gtk.drag_dest_set (this, Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.MOTION, Application.DRAG_AND_DROP_TASK_DATA, Gdk.DragAction.MOVE); - - drag_motion.connect (on_drag_motion); - drag_drop.connect (on_drag_drop); - drag_data_received.connect (on_drag_data_received); - drag_leave.connect (on_drag_leave); - } - - private bool on_drag_motion (Gdk.DragContext context, int x, int y, uint time) { - var style_context = get_style_context (); - if (!style_context.has_class ("drop-hover")) { - style_context.add_class ("drop-hover"); - } - return true; - } - - private void on_drag_leave (Gdk.DragContext context, uint time_) { - get_style_context ().remove_class ("drop-hover"); - } - - private Gee.HashMultiMap received_drag_data; - - private async bool on_drag_drop_move_tasks () throws Error { - E.SourceRegistry registry = yield Application.model.get_registry (); - var move_successful = true; - - var source_uids = received_drag_data.get_keys (); - foreach (var source_uid in source_uids) { - var src_source = registry.ref_source (source_uid); - - var component_uids = received_drag_data.get (source_uid); - foreach (var component_uid in component_uids) { - if (!yield Application.model.move_task (src_source, source, component_uid)) { - move_successful = false; - } - } - } - return move_successful; - } - - private bool on_drag_drop (Gdk.DragContext context, int x, int y, uint time) { - var target = Gtk.drag_dest_find_target (this, context, null); - if (target != Gdk.Atom.NONE) { - Gtk.drag_get_data (this, context, target, time); - } - - var drop_successful = false; - var move_successful = false; - if (received_drag_data != null && received_drag_data.size > 0) { - drop_successful = true; - - on_drag_drop_move_tasks.begin ((obj, res) => { - try { - move_successful = on_drag_drop_move_tasks.end (res); - - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Moving task failed"), - _("There was an error while moving the task to the desired list."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); - error_dialog.destroy (); - - } finally { - Gtk.drag_finish (context, drop_successful, move_successful, time); - } - }); - } - - return drop_successful; - } - - private void on_drag_data_received (Gdk.DragContext context, int x, int y, Gtk.SelectionData selection_data, uint info, uint time) { - received_drag_data = new Gee.HashMultiMap (); - - var uri_scheme = "task://"; - var uris = selection_data.get_uris (); - - foreach (var uri in uris) { - string? source_uid = null; - string? component_uid = null; - - if (uri.has_prefix (uri_scheme)) { - var uri_parts = uri.substring (uri_scheme.length).split ("/"); - - if (uri_parts.length == 2) { - source_uid = uri_parts[0]; - component_uid = uri_parts[1]; - } - } - - if (source_uid == null || component_uid == null) { - warning ("Can't handle drop data: Unexpected uri format: %s", uri); - - } else if (source_uid == source.uid) { - debug ("Dropped task onto the same list, so we have nothing to do."); - - } else { - received_drag_data.set (source_uid, component_uid); - } - } - } + // private void build_drag_and_drop () { + // Gtk.drag_dest_set (this, Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.MOTION, Application.DRAG_AND_DROP_TASK_DATA, Gdk.DragAction.MOVE); + + // drag_motion.connect (on_drag_motion); + // drag_drop.connect (on_drag_drop); + // drag_data_received.connect (on_drag_data_received); + // drag_leave.connect (on_drag_leave); + // } + + // private bool on_drag_motion (Gdk.DragContext context, int x, int y, uint time) { + // var style_context = get_style_context (); + // if (!style_context.has_class ("drop-hover")) { + // style_context.add_class ("drop-hover"); + // } + // return true; + // } + + // private void on_drag_leave (Gdk.DragContext context, uint time_) { + // get_style_context ().remove_class ("drop-hover"); + // } + + // private Gee.HashMultiMap received_drag_data; + + // private async bool on_drag_drop_move_tasks () throws Error { + // E.SourceRegistry registry = yield Application.model.get_registry (); + // var move_successful = true; + + // var source_uids = received_drag_data.get_keys (); + // foreach (var source_uid in source_uids) { + // var src_source = registry.ref_source (source_uid); + + // var component_uids = received_drag_data.get (source_uid); + // foreach (var component_uid in component_uids) { + // if (!yield Application.model.move_task (src_source, source, component_uid)) { + // move_successful = false; + // } + // } + // } + // return move_successful; + // } + + // private bool on_drag_drop (Gdk.DragContext context, int x, int y, uint time) { + // var target = Gtk.drag_dest_find_target (this, context, null); + // if (target != Gdk.Atom.NONE) { + // Gtk.drag_get_data (this, context, target, time); + // } + + // var drop_successful = false; + // var move_successful = false; + // if (received_drag_data != null && received_drag_data.size > 0) { + // drop_successful = true; + + // on_drag_drop_move_tasks.begin ((obj, res) => { + // try { + // move_successful = on_drag_drop_move_tasks.end (res); + + // } catch (Error e) { + // var error_dialog = new Granite.MessageDialog ( + // _("Moving task failed"), + // _("There was an error while moving the task to the desired list."), + // new ThemedIcon ("dialog-error"), + // Gtk.ButtonsType.CLOSE + // ); + // error_dialog.show_error_details (e.message); + // error_dialog.run (); + // error_dialog.destroy (); + + // } finally { + // Gtk.drag_finish (context, drop_successful, move_successful, time); + // } + // }); + // } + + // return drop_successful; + // } + + // private void on_drag_data_received (Gdk.DragContext context, int x, int y, Gtk.SelectionData selection_data, uint info, uint time) { + // received_drag_data = new Gee.HashMultiMap (); + + // var uri_scheme = "task://"; + // var uris = selection_data.get_uris (); + + // foreach (var uri in uris) { + // string? source_uid = null; + // string? component_uid = null; + + // if (uri.has_prefix (uri_scheme)) { + // var uri_parts = uri.substring (uri_scheme.length).split ("/"); + + // if (uri_parts.length == 2) { + // source_uid = uri_parts[0]; + // component_uid = uri_parts[1]; + // } + // } + + // if (source_uid == null || component_uid == null) { + // warning ("Can't handle drop data: Unexpected uri format: %s", uri); + + // } else if (source_uid == source.uid) { + // debug ("Dropped task onto the same list, so we have nothing to do."); + + // } else { + // received_drag_data.set (source_uid, component_uid); + // } + // } + // } public void update_request () { Tasks.Application.set_task_color (source, source_color); diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 305e10453e..f8a35c1271 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -55,16 +55,16 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { valign = Gtk.Align.CENTER, tooltip_text = _("Edit Name and Appearance"), popover = list_settings_popover, - image = new Gtk.Image.from_icon_name ("view-more-symbolic", Gtk.IconSize.MENU) + icon_name = "view-more-symbolic" }; - settings_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); - settings_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + settings_button.get_style_context ().add_class (Granite.STYLE_CLASS_FLAT); + settings_button.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); var placeholder = new Gtk.Label (_("No Tasks")); placeholder.show (); unowned Gtk.StyleContext placeholder_context = placeholder.get_style_context (); - placeholder_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); + placeholder_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); placeholder_context.add_class (Granite.STYLE_CLASS_H2_LABEL); add_task_list = new Gtk.ListBox () { @@ -72,33 +72,31 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { selection_mode = Gtk.SelectionMode.SINGLE, activate_on_single_click = true }; - add_task_list.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND); + add_task_list.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); var add_task_row = new Tasks.Widgets.TaskRow.for_source (source); add_task_row.unselect.connect (on_row_unselect); add_task_row.task_changed.connect ((task) => { Tasks.Application.model.add_task.begin (source, task, (obj, res) => { - GLib.Idle.add (() => { - try { - Tasks.Application.model.add_task.end (res); - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Adding task failed"), - _("The task list registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Tasks.Application.model.add_task.end (res); + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Adding task failed"), + _("The task list registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); - add_task_list.add (add_task_row); + add_task_list.append (add_task_row); task_list = new Gtk.ListBox () { selection_mode = Gtk.SelectionMode.MULTIPLE, @@ -106,13 +104,14 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }; task_list.set_placeholder (placeholder); task_list.set_sort_func (sort_function); - task_list.get_style_context ().add_class (Gtk.STYLE_CLASS_BACKGROUND); + task_list.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); - var scrolled_window = new Gtk.ScrolledWindow (null, null) { - expand = true, + var scrolled_window = new Gtk.ScrolledWindow () { + hexpand = true, + vexpand = true, hscrollbar_policy = Gtk.PolicyType.NEVER }; - scrolled_window.add (task_list); + scrolled_window.child = task_list; column_spacing = 12; attach (editable_title, 0, 0); @@ -125,65 +124,63 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }); on_show_completed_changed (Application.settings.get_boolean ("show-completed")); - settings_button.toggled.connect (() => { - unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - - if (settings_button.active) { - list_settings_popover.source = source; - - if (win_action_map != null) { - ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); - } - - } else if (win_action_map != null) { - /* - * We can't immediate disable the action once the popover is closed, - * because this would lead to the action not beeing executed in case - * the popover was closed because the user clicked on the action. - * Therefore we wait a tiny bit using GLib.Idle to allow the action to - * be executed if needed. - */ - GLib.Idle.add (() => { - ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled ( - add_task_list.get_selected_rows ().length () == 0 && - task_list.get_selected_rows ().length () == 0 - ); - return GLib.Source.REMOVE; - }); - } - }); + // settings_button.activate.connect (() => { + // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); + + // if (settings_button.active) { + // list_settings_popover.source = source; + + // if (win_action_map != null) { + // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); + // } + + // } else if (win_action_map != null) { + // /* + // * We can't immediate disable the action once the popover is closed, + // * because this would lead to the action not beeing executed in case + // * the popover was closed because the user clicked on the action. + // * Therefore we wait a tiny bit using GLib.Idle to allow the action to + // * be executed if needed. + // */ + // GLib.Idle.add (() => { + // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled ( + // add_task_list.get_selected_rows ().length () == 0 && + // task_list.get_selected_rows ().length () == 0 + // ); + // return GLib.Source.REMOVE; + // }); + // } + // }); add_task_list.row_activated.connect (on_row_activated); task_list.row_activated.connect (on_row_activated); - editable_title.notify["editing"].connect (() => { - unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - if (win_action_map != null) { - ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (!editable_title.editing); - } - }); + // editable_title.notify["editing"].connect (() => { + // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); + // if (win_action_map != null) { + // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (!editable_title.editing); + // } + // }); editable_title.changed.connect (() => { Application.model.update_task_list_display_name.begin (source, editable_title.text, (obj, res) => { - GLib.Idle.add (() => { - try { - Application.model.update_task_list_display_name.end (res); - } catch (Error e) { - editable_title.text = source.display_name; - - var error_dialog = new Granite.MessageDialog ( - _("Renaming task list failed"), - _("The task list registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Application.model.update_task_list_display_name.end (res); + } catch (Error e) { + editable_title.text = source.display_name; + + var error_dialog = new Granite.MessageDialog ( + _("Renaming task list failed"), + _("The task list registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); } @@ -197,9 +194,11 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } private void set_view_for_query (string query) { - var children = task_list.get_children (); - foreach (unowned var child in children) { + unowned var child = task_list.get_first_child (); + while (child != null) { task_list.remove (child); + + child = child.get_next_sibling (); } if (view != null) { @@ -222,10 +221,10 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var task_row = (Tasks.Widgets.TaskRow) row; task_row.reveal_child_request (true); - unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - if (win_action_map != null) { - ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); - } + // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); + // if (win_action_map != null) { + // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + // } } private void on_row_unselect (Gtk.ListBoxRow row) { @@ -233,12 +232,12 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { ((Gtk.ListBox) row.parent).unselect_row (row); } - if (add_task_list.get_selected_rows ().length () == 0 && task_list.get_selected_rows ().length () == 0) { - unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - if (win_action_map != null) { - ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); - } - } + // if (add_task_list.get_selected_rows ().length () == 0 && task_list.get_selected_rows ().length () == 0) { + // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); + // if (win_action_map != null) { + // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); + // } + // } } public void update_request () { @@ -246,12 +245,15 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { Tasks.Application.set_task_color (source, editable_title); - task_list.@foreach ((row) => { - if (row is Tasks.Widgets.TaskRow) { - var task_row = (row as Tasks.Widgets.TaskRow); + unowned var child = task_list.get_first_child (); + while (child != null) { + if (child is Tasks.Widgets.TaskRow) { + unowned var task_row = (child as Tasks.Widgets.TaskRow); task_row.update_request (); } - }); + + child = child.get_next_sibling (); + } } [CCode (instance_pos = -1)] @@ -299,70 +301,64 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { task_row.task_completed.connect ((task) => { Tasks.Application.model.complete_task.begin (source, task, (obj, res) => { - GLib.Idle.add (() => { - try { - Tasks.Application.model.complete_task.end (res); - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Completing task failed"), - _("The task registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Tasks.Application.model.complete_task.end (res); + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Completing task failed"), + _("The task registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); task_row.task_changed.connect ((task) => { Tasks.Application.model.update_task.begin (source, task, ECal.ObjModType.THIS_AND_FUTURE, (obj, res) => { - GLib.Idle.add (() => { - try { - Tasks.Application.model.update_task.end (res); - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Updating task failed"), - _("The task registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Tasks.Application.model.update_task.end (res); + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Updating task failed"), + _("The task registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); task_row.task_removed.connect ((task) => { Tasks.Application.model.remove_task.begin (source, task, ECal.ObjModType.ALL, (obj, res) => { - GLib.Idle.add (() => { - try { - Tasks.Application.model.remove_task.end (res); - } catch (Error e) { - var error_dialog = new Granite.MessageDialog ( - _("Removing task failed"), - _("The task registry may be unavailable or unable to be written to."), - new ThemedIcon ("dialog-error"), - Gtk.ButtonsType.CLOSE - ); - error_dialog.show_error_details (e.message); - error_dialog.run (); + try { + Tasks.Application.model.remove_task.end (res); + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Removing task failed"), + _("The task registry may be unavailable or unable to be written to."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { error_dialog.destroy (); - } - - return GLib.Source.REMOVE; - }); + }); + } }); }); - task_list.add (task_row); + task_list.append (task_row); return true; }); diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 5970a13d3b..8061e34401 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -35,10 +35,10 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Tasks.Widgets.EntryPopover.DateTime due_datetime_popover; private Gtk.Revealer due_datetime_popover_revealer; - private Tasks.Widgets.EntryPopover.Location location_popover; - private Gtk.Revealer location_popover_revealer; + // private Tasks.Widgets.EntryPopover.Location location_popover; + // private Gtk.Revealer location_popover_revealer; - private Gtk.EventBox event_box; + // private Gtk.EventBox event_box; private Gtk.Stack state_stack; private Gtk.Image icon; private Gtk.CheckButton check; @@ -87,8 +87,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { warning ("unable to get the registry, assuming task is not from gtask"); } - icon = new Gtk.Image.from_icon_name ("list-add-symbolic", Gtk.IconSize.MENU); - icon.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + icon = new Gtk.Image.from_icon_name ("list-add-symbolic"); + icon.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); check = new Gtk.CheckButton () { valign = Gtk.Align.CENTER @@ -97,13 +97,13 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { state_stack = new Gtk.Stack () { transition_type = Gtk.StackTransitionType.CROSSFADE }; - state_stack.add (icon); - state_stack.add (check); + state_stack.add_child (icon); + state_stack.add_child (check); summary_entry = new Gtk.Entry (); unowned Gtk.StyleContext summary_entry_context = summary_entry.get_style_context (); - summary_entry_context.add_class (Gtk.STYLE_CLASS_FLAT); + summary_entry_context.add_class (Granite.STYLE_CLASS_FLAT); summary_entry_context.add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); due_datetime_popover = new Tasks.Widgets.EntryPopover.DateTime (); @@ -115,9 +115,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { due_datetime_popover_revealer = new Gtk.Revealer () { margin_end = 6, reveal_child = false, - transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT + transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT, + child = due_datetime_popover }; - due_datetime_popover_revealer.add (due_datetime_popover); due_datetime_popover.value_format.connect ((value) => { due_datetime_popover.get_style_context ().remove_class ("error"); @@ -162,68 +162,68 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } }); - location_popover = new Tasks.Widgets.EntryPopover.Location (); - - location_popover_revealer = new Gtk.Revealer () { - margin_end = 6, - reveal_child = false, - transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT - }; - location_popover_revealer.add (location_popover); - - location_popover.value_format.connect ((value) => { - if (value == null) { - return null; - } - var location = (value.display_name == null ? value.postal_address : value.display_name); - - switch (value.proximity) { - case Tasks.LocationProximity.ARRIVE: - return _("Arriving: %s").printf (location); - - case Tasks.LocationProximity.DEPART: - return _("Leaving: %s").printf (location); - - default: - return location; - } - }); - - location_popover.value_changed.connect ((value) => { - if (!task_form_revealer.reveal_child) { - if (value == null) { - location_popover_revealer.reveal_child = false; - } - save_task (task); - } - }); + // location_popover = new Tasks.Widgets.EntryPopover.Location (); + + // location_popover_revealer = new Gtk.Revealer () { + // margin_end = 6, + // reveal_child = false, + // transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT + // }; + // location_popover_revealer.add (location_popover); + + // location_popover.value_format.connect ((value) => { + // if (value == null) { + // return null; + // } + // var location = (value.display_name == null ? value.postal_address : value.display_name); + + // switch (value.proximity) { + // case Tasks.LocationProximity.ARRIVE: + // return _("Arriving: %s").printf (location); + + // case Tasks.LocationProximity.DEPART: + // return _("Leaving: %s").printf (location); + + // default: + // return location; + // } + // }); + + // location_popover.value_changed.connect ((value) => { + // if (!task_form_revealer.reveal_child) { + // if (value == null) { + // location_popover_revealer.reveal_child = false; + // } + // save_task (task); + // } + // }); description_label = new Gtk.Label (null) { xalign = 0, lines = 1, ellipsize = Pango.EllipsizeMode.END }; - description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + description_label.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); // Should not use a transition that varies the width else label aligning and ellipsizing is incorrect. description_label_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.CROSSFADE, - reveal_child = false + reveal_child = false, + child = description_label }; - description_label_revealer.add (description_label); - var task_grid = new Gtk.Grid (); - task_grid.add (due_datetime_popover_revealer); - task_grid.add (location_popover_revealer); - task_grid.add (description_label_revealer); + var task_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + task_box.append (due_datetime_popover_revealer); + // task_box.append (location_popover_revealer); + task_box.append (description_label_revealer); task_detail_revealer = new Gtk.Revealer () { - transition_type = Gtk.RevealerTransitionType.SLIDE_UP + transition_type = Gtk.RevealerTransitionType.SLIDE_UP, + child = task_box }; - task_detail_revealer.add (task_grid); var description_textview = new Granite.HyperTextView () { - border_width = 12, + // border_width = 12, height_request = 140, accepts_tab = false }; @@ -233,40 +233,41 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { description_textview.set_buffer (description_textbuffer); var description_frame = new Gtk.Frame (null) { - hexpand = true + hexpand = true, + child = description_textview }; - description_frame.add (description_textview); var cancel_button = new Gtk.Button.with_label (_("Cancel")); var save_button = new Gtk.Button.with_label (created ? _("Save Changes") : _("Add Task")); - save_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + save_button.get_style_context ().add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); - var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL) { + var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { baseline_position = Gtk.BaselinePosition.CENTER, margin_top = 12, spacing = 6 }; - button_box.set_layout (Gtk.ButtonBoxStyle.END); - button_box.add (cancel_button); - button_box.add (save_button); - - var form_grid = new Gtk.Grid () { - column_spacing = 12, - row_spacing = 12, - margin_top = margin_bottom = 6 + // button_box.set_layout (Gtk.ButtonBoxStyle.END); + button_box.append (cancel_button); + button_box.append (save_button); + + var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) { + margin_top = 6, + margin_bottom = 6 }; - form_grid.attach (description_frame, 0, 0); - form_grid.attach (button_box, 0, 1); + form_box.append (description_frame); + form_box.append (button_box); task_form_revealer = new Gtk.Revealer () { - transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN + transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN, + child = form_box }; - task_form_revealer.add (form_grid); var grid = new Gtk.Grid () { - margin = 6, - margin_start = margin_end = 12, + margin_top = 6, + margin_bottom = 6, + margin_start = 12, + margin_end = 12, column_spacing = 6, row_spacing = 3 }; @@ -276,23 +277,24 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { grid.attach (task_form_revealer, 1, 2); revealer = new Gtk.Revealer () { - reveal_child = true + reveal_child = true, + transition_type = Gtk.RevealerTransitionType.SLIDE_UP, + child = grid }; - revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_UP; - revealer.add (grid); - event_box = new Gtk.EventBox () { - expand = true, - above_child = false - }; - event_box.add_events ( - Gdk.EventMask.BUTTON_PRESS_MASK | - Gdk.EventMask.BUTTON_RELEASE_MASK - ); - event_box.add (revealer); + // event_box = new Gtk.EventBox () { + // expand = true, + // above_child = false + // }; + // event_box.add_events ( + // Gdk.EventMask.BUTTON_PRESS_MASK | + // Gdk.EventMask.BUTTON_RELEASE_MASK + // ); + // event_box.add (revealer); - add (event_box); - margin_start = margin_end = 12; + child = revealer; + margin_start = 12; + margin_end = 12; style_context = get_style_context (); style_context.add_class (Granite.STYLE_CLASS_ROUNDED); @@ -303,10 +305,10 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { state_stack.visible_child = check; var delete_button = new Gtk.Button.with_label (_("Delete Task")); - delete_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); + delete_button.get_style_context ().add_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); - button_box.add (delete_button); - button_box.set_child_secondary (delete_button, true); + button_box.append (delete_button); + button_box.append (delete_button); delete_button.clicked.connect (() => { end_editing (); @@ -315,7 +317,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { }); } - build_drag_and_drop (); + // build_drag_and_drop (); + + var key_controller = new Gtk.EventControllerKey (); check.toggled.connect (() => { if (task == null) { @@ -331,17 +335,17 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { end_editing (); }); - summary_entry.grab_focus.connect (() => { - activate (); - }); + // summary_entry.grab_focus.connect (() => { + // activate (); + // }); cancel_button.clicked.connect (() => { reset_form (); end_editing (); }); - key_release_event.connect ((event) => { - if (event.keyval == Gdk.Key.Escape) { + key_controller.key_released.connect ((keyval, keycode, state) => { + if (keyval == Gdk.Key.Escape) { reset_form (); end_editing (); } @@ -378,7 +382,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { summary_entry.text = icalcomponent.get_summary () == null ? "" : icalcomponent.get_summary (); // vala-lint=line-length description_textbuffer.text = icalcomponent.get_description () == null ? "" : icalcomponent.get_description (); // vala-lint=line-length due_datetime_popover.value = icalcomponent.get_due ().is_null_time () ? null : Util.ical_to_date_time_local (icalcomponent.get_due ()); // vala-lint=line-length - location_popover.value = Util.get_ecalcomponent_location (task); + // location_popover.value = Util.get_ecalcomponent_location (task); } private void save_task (ECal.Component task) { @@ -402,7 +406,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { ical_task.set_due (new_icaltime); ical_task.set_dtstart (new_icaltime); - Util.set_ecalcomponent_location (task, location_popover.value); + // Util.set_ecalcomponent_location (task, location_popover.value); ical_task.set_summary (summary_entry.text); ical_task.set_description (description_textbuffer.text); @@ -439,13 +443,13 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { completed = false; check.active = completed; summary_entry.text = ""; - summary_entry.get_style_context ().remove_class (Gtk.STYLE_CLASS_DIM_LABEL); + summary_entry.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); summary_entry.get_style_context ().add_class ("add-task"); task_detail_revealer.reveal_child = false; - task_detail_revealer.get_style_context ().remove_class (Gtk.STYLE_CLASS_DIM_LABEL); + task_detail_revealer.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); due_datetime_popover_revealer.reveal_child = false; - location_popover_revealer.reveal_child = false; + // location_popover_revealer.reveal_child = false; description_label_revealer.reveal_child = false; description_textbuffer.text = ""; @@ -467,11 +471,11 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { summary_entry.get_style_context ().remove_class ("add-task"); if (completed) { - summary_entry.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); - task_detail_revealer.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + summary_entry.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); + task_detail_revealer.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); } else { - summary_entry.get_style_context ().remove_class (Gtk.STYLE_CLASS_DIM_LABEL); - task_detail_revealer.get_style_context ().remove_class (Gtk.STYLE_CLASS_DIM_LABEL); + summary_entry.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); + task_detail_revealer.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); } if (ical_task.get_due ().is_null_time ()) { @@ -482,13 +486,13 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { due_datetime_popover_revealer.reveal_child = true; } - var location = Util.get_ecalcomponent_location (task); - if (location == null) { - location_popover_revealer.reveal_child = false; - } else { - location_popover.value = location; - location_popover_revealer.reveal_child = true; - } + // var location = Util.get_ecalcomponent_location (task); + // if (location == null) { + // location_popover_revealer.reveal_child = false; + // } else { + // location_popover.value = location; + // location_popover_revealer.reveal_child = true; + // } if (ical_task.get_description () == null) { description_label.label = ""; @@ -513,11 +517,11 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private void task_details_reveal_request (bool value) { description_label_revealer.reveal_child = value && description_label.label != null && description_label.label.strip ().length > 0; due_datetime_popover_revealer.reveal_child = !value || due_datetime_popover.value != null; - location_popover_revealer.reveal_child = !value || location_popover.value != null; + // location_popover_revealer.reveal_child = !value || location_popover.value != null; task_detail_revealer.reveal_child = description_label_revealer.reveal_child || - due_datetime_popover_revealer.reveal_child || - location_popover_revealer.reveal_child; + due_datetime_popover_revealer.reveal_child; + // location_popover_revealer.reveal_child; } private void remove_request () { @@ -544,50 +548,50 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { return created.is_valid_time (); } - private void build_drag_and_drop () { - if (!created || is_scheduled_view) { - return; - } - Gtk.drag_source_set (event_box, Gdk.ModifierType.BUTTON1_MASK, Application.DRAG_AND_DROP_TASK_DATA, Gdk.DragAction.MOVE); - - event_box.drag_begin.connect (on_drag_begin); - event_box.drag_data_get.connect (on_drag_data_get); - event_box.drag_data_delete.connect (on_drag_data_delete); - } - - private void on_drag_begin (Gdk.DragContext context) { - Gtk.Allocation alloc; - get_allocation (out alloc); - - var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, alloc.width, alloc.height); - var cairo_context = new Cairo.Context (surface); - - var style_context = get_style_context (); - var had_cards_class = style_context.has_class (Granite.STYLE_CLASS_CARD); - - style_context.add_class ("drag-active"); - if (had_cards_class) { - style_context.remove_class (Granite.STYLE_CLASS_CARD); - } - draw_to_cairo_context (cairo_context); - if (had_cards_class) { - style_context.add_class (Granite.STYLE_CLASS_CARD); - } - style_context.remove_class ("drag-active"); - - int drag_icon_x, drag_icon_y; - translate_coordinates (this, 0, 0, out drag_icon_x, out drag_icon_y); - surface.set_device_offset (-drag_icon_x, -drag_icon_y); - - Gtk.drag_set_icon_surface (context, surface); - } - - private void on_drag_data_get (Gtk.Widget widget, Gdk.DragContext context, Gtk.SelectionData selection_data, uint target_type, uint time) { - var task_uri = "task://%s/%s".printf (source.uid, task.get_uid ()); - selection_data.set_uris ({ task_uri }); - } - - private void on_drag_data_delete (Gdk.DragContext context) { - destroy (); - } + // private void build_drag_and_drop () { + // if (!created || is_scheduled_view) { + // return; + // } + // Gtk.drag_source_set (event_box, Gdk.ModifierType.BUTTON1_MASK, Application.DRAG_AND_DROP_TASK_DATA, Gdk.DragAction.MOVE); + + // event_box.drag_begin.connect (on_drag_begin); + // event_box.drag_data_get.connect (on_drag_data_get); + // event_box.drag_data_delete.connect (on_drag_data_delete); + // } + + // private void on_drag_begin (Gdk.DragContext context) { + // Gtk.Allocation alloc; + // get_allocation (out alloc); + + // var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, alloc.width, alloc.height); + // var cairo_context = new Cairo.Context (surface); + + // var style_context = get_style_context (); + // var had_cards_class = style_context.has_class (Granite.STYLE_CLASS_CARD); + + // style_context.add_class ("drag-active"); + // if (had_cards_class) { + // style_context.remove_class (Granite.STYLE_CLASS_CARD); + // } + // draw_to_cairo_context (cairo_context); + // if (had_cards_class) { + // style_context.add_class (Granite.STYLE_CLASS_CARD); + // } + // style_context.remove_class ("drag-active"); + + // int drag_icon_x, drag_icon_y; + // translate_coordinates (this, 0, 0, out drag_icon_x, out drag_icon_y); + // surface.set_device_offset (-drag_icon_x, -drag_icon_y); + + // Gtk.drag_set_icon_surface (context, surface); + // } + + // private void on_drag_data_get (Gtk.Widget widget, Gdk.DragContext context, Gtk.SelectionData selection_data, uint target_type, uint time) { + // var task_uri = "task://%s/%s".printf (source.uid, task.get_uid ()); + // selection_data.set_uris ({ task_uri }); + // } + + // private void on_drag_data_delete (Gdk.DragContext context) { + // destroy (); + // } } From 18e8ac0df643196d4ff87e8e1e4fabb80cbfdb86 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 20:04:36 +0900 Subject: [PATCH 03/86] Fix CSS errors --- data/EntryPopover.css | 2 +- data/SourceRow.css | 6 +++--- data/TaskRow.css | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/data/EntryPopover.css b/data/EntryPopover.css index 4c024df936..4436eeaa74 100644 --- a/data/EntryPopover.css +++ b/data/EntryPopover.css @@ -30,7 +30,7 @@ entry-popover button { } entry-popover.error grid { - background: alpha (@error_color, 0.2); + background: alpha(@error_color, 0.2); } entry-popover.error button { diff --git a/data/SourceRow.css b/data/SourceRow.css index be810a7444..620c553379 100644 --- a/data/SourceRow.css +++ b/data/SourceRow.css @@ -23,9 +23,9 @@ border: 1px solid @borders; border-radius: 50%; box-shadow: - inset 0 1px 0 0 alpha (@inset_dark_color, 0.7), - inset 0 0 0 1px alpha (@inset_dark_color, 0.3), - 0 1px 0 0 alpha (@bg_highlight_color, 0.3); + inset 0 1px 0 0 alpha(@inset_dark_color, 0.7), + inset 0 0 0 1px alpha(@inset_dark_color, 0.3), + 0 1px 0 0 alpha(@bg_highlight_color, 0.3); min-height: 14px; min-width: 14px; } diff --git a/data/TaskRow.css b/data/TaskRow.css index 751fb066db..f178cb90ed 100644 --- a/data/TaskRow.css +++ b/data/TaskRow.css @@ -45,7 +45,7 @@ row entry.flat:focus { } row:not(.card) entry.add-task { - border-color: alpha (@text_color, 0.25); + border-color: alpha(@text_color, 0.25); } row.drag-active { From 0b956effd0da73c8ed9a0c0aa3adb13ba4b6b96b Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 20:17:12 +0900 Subject: [PATCH 04/86] Some fixes --- data/TaskRow.css | 2 +- src/Widgets/EditableLabel.vala | 11 +++++++---- src/Widgets/EntryPopover/Generic.vala | 7 +++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data/TaskRow.css b/data/TaskRow.css index f178cb90ed..2e4bc04e48 100644 --- a/data/TaskRow.css +++ b/data/TaskRow.css @@ -23,7 +23,7 @@ row { } row:focus:not(.card) { - background-color: shade (@base_color, 0.8); + background-color: shade(@base_color, 0.8); } row.card { diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index c235b9f835..352ad4dadc 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -50,6 +50,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { } static construct { + set_layout_manager_type (typeof (Gtk.BinLayout)); label_provider = new Gtk.CssProvider (); label_provider.load_from_resource ("io/elementary/tasks/EditableLabel.css"); } @@ -61,6 +62,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { valign = Gtk.Align.CENTER; + warning ("Adding controllers (EditableLabel)"); var motion_controller = new Gtk.EventControllerMotion (); add_controller (motion_controller); @@ -69,6 +71,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { var focus_controller = new Gtk.EventControllerFocus (); entry.add_controller (focus_controller); + warning ("Added controllers (EditableLabel)"); title = new Gtk.Label ("") { ellipsize = Pango.EllipsizeMode.END, @@ -121,10 +124,6 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { editing = true; }); - edit_button.clicked.connect (() => { - editing = true; - }); - entry.activate.connect (() => { if (stack.visible_child == entry) { editing = false; @@ -143,4 +142,8 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { return Gdk.EVENT_STOP; } + + ~EditableLabel () { + get_last_child ().unparent (); + } } diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 0f273c73a3..5799e55390 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -42,13 +42,16 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { } static construct { + set_layout_manager_type (typeof (Gtk.BinLayout)); style_provider = new Gtk.CssProvider (); style_provider.load_from_resource ("io/elementary/tasks/EntryPopover.css"); } construct { + warning ("Adding controllers (Generic)"); var motion_controller = new Gtk.EventControllerMotion (); add_controller (motion_controller); + warning ("Added controllers (Generic)"); popover = new Gtk.Popover () { child = popover_button @@ -142,4 +145,8 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { }); }); } + + ~Generic () { + get_last_child ().unparent (); + } } From 8e8edf1da1d9136fd93718c6d73abe48ba8437d3 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 20:34:01 +0900 Subject: [PATCH 05/86] Fix headers --- src/Application.vala | 1 - src/MainWindow.vala | 55 ++++++++++++++------------- src/Widgets/EditableLabel.vala | 8 ++-- src/Widgets/EntryPopover/Generic.vala | 4 +- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index e7ee3f9e00..27710a271d 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -88,7 +88,6 @@ public class Tasks.Application : Gtk.Application { } active_window.present (); - warning ("Presented"); } private static Gee.HashMap? providers; diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 2fdb1c7674..0ba27861e1 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -62,30 +62,20 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { ); } - var sidebar_header = new Gtk.HeaderBar () { - title_widget = new Gtk.Label (null), - show_title_buttons = true - }; - - unowned Gtk.StyleContext sidebar_header_context = sidebar_header.get_style_context (); - sidebar_header_context.add_class ("default-decoration"); - sidebar_header_context.add_class (Granite.STYLE_CLASS_FLAT); - - var main_header = new Gtk.HeaderBar () { - title_widget = new Gtk.Label (null), - show_title_buttons = true - }; - - unowned Gtk.StyleContext main_header_context = main_header.get_style_context (); - main_header_context.add_class ("default-decoration"); - main_header_context.add_class (Granite.STYLE_CLASS_FLAT); - listbox = new Gtk.ListBox (); listbox.set_sort_func (sort_function); var scheduled_row = new Tasks.Widgets.ScheduledRow (); listbox.append (scheduled_row); + var sidebar_header = new Gtk.HeaderBar () { + title_widget = new Gtk.Label (null), + show_title_buttons = false + }; + sidebar_header.pack_start (new Gtk.WindowControls (Gtk.PackType.START)); + sidebar_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); + sidebar_header.add_css_class (Granite.STYLE_CLASS_FLAT); + var scrolledwindow = new Gtk.ScrolledWindow () { hexpand = true, vexpand = true, @@ -120,9 +110,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var actionbar = new Gtk.ActionBar (); actionbar.pack_start (add_tasklist_button); - - unowned Gtk.StyleContext actionbar_style_context = actionbar.get_style_context (); - actionbar_style_context.add_class (Granite.STYLE_CLASS_FLAT); + actionbar.add_css_class (Granite.STYLE_CLASS_FLAT); var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); sidebar.append (sidebar_header); @@ -132,20 +120,35 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { unowned Gtk.StyleContext sidebar_style_context = sidebar.get_style_context (); sidebar_style_context.add_class (Granite.STYLE_CLASS_SIDEBAR); + var main_header = new Gtk.HeaderBar () { + title_widget = new Gtk.Label (null), + show_title_buttons = false + }; + main_header.pack_end (new Gtk.WindowControls (Gtk.PackType.END)); + main_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); + main_header.add_css_class (Granite.STYLE_CLASS_FLAT); + task_list_grid_stack = new Gtk.Stack (); var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - main_box.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); + main_box.add_css_class (Granite.STYLE_CLASS_BACKGROUND); main_box.append (main_header); main_box.append (task_list_grid_stack); - var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); - paned.start_child = sidebar; // (sidebar, false, false); - paned.end_child = main_box; // (main_box, true, false); - paned.resize_end_child = true; // ??? + var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL) { + start_child = sidebar, // (sidebar, false, false); + end_child = main_box, // (main_box, true, false); + resize_end_child = true // ??? + }; child = paned; + // We need to hide the title area for the split headerbar + var null_title = new Gtk.Grid () { + visible = false + }; + set_titlebar (null_title); + var settings = new GLib.Settings ("io.elementary.tasks"); settings.bind ("window-width", this, "default-width", SettingsBindFlags.DEFAULT); settings.bind ("window-height", this, "default-height", SettingsBindFlags.DEFAULT); diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index 352ad4dadc..d082126340 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -62,17 +62,12 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { valign = Gtk.Align.CENTER; - warning ("Adding controllers (EditableLabel)"); var motion_controller = new Gtk.EventControllerMotion (); add_controller (motion_controller); var press_controller = new Gtk.GestureClick (); add_controller (press_controller); - var focus_controller = new Gtk.EventControllerFocus (); - entry.add_controller (focus_controller); - warning ("Added controllers (EditableLabel)"); - title = new Gtk.Label ("") { ellipsize = Pango.EllipsizeMode.END, xalign = 0 @@ -101,6 +96,9 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { }; entry.get_style_context ().add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + var focus_controller = new Gtk.EventControllerFocus (); + entry.add_controller (focus_controller); + stack = new Gtk.Stack () { hhomogeneous = false, transition_type = Gtk.StackTransitionType.CROSSFADE diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 5799e55390..63caa35100 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -47,11 +47,9 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { style_provider.load_from_resource ("io/elementary/tasks/EntryPopover.css"); } - construct { - warning ("Adding controllers (Generic)"); + construct { var motion_controller = new Gtk.EventControllerMotion (); add_controller (motion_controller); - warning ("Added controllers (Generic)"); popover = new Gtk.Popover () { child = popover_button From 62b389ab8ad6d34f699be1cb9ca4fc22ef8760f4 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 21:22:58 +0900 Subject: [PATCH 06/86] Use `add_css_class` and fix some warnings --- src/MainWindow.vala | 124 +++++++++++++------------ src/Widgets/EditableLabel.vala | 7 +- src/Widgets/EntryPopover/DateTime.vala | 2 +- src/Widgets/EntryPopover/Generic.vala | 10 +- src/Widgets/ListSettingsPopover.vala | 60 +++++------- src/Widgets/ScheduledTaskListGrid.vala | 12 +-- src/Widgets/SourceRow.vala | 5 +- src/Widgets/TaskListGrid.vala | 112 +++++++++++----------- src/Widgets/TaskRow.vala | 47 +++++----- 9 files changed, 185 insertions(+), 194 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 0ba27861e1..177a997cc6 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -113,13 +113,11 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { actionbar.add_css_class (Granite.STYLE_CLASS_FLAT); var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + sidebar.add_css_class (Granite.STYLE_CLASS_SIDEBAR); sidebar.append (sidebar_header); sidebar.append (scrolledwindow); sidebar.append (actionbar); - unowned Gtk.StyleContext sidebar_style_context = sidebar.get_style_context (); - sidebar_style_context.add_class (Granite.STYLE_CLASS_SIDEBAR); - var main_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), show_title_buttons = false @@ -178,65 +176,16 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } listbox.set_header_func (header_update_func); - listbox.row_selected.connect ((row) => { - if (row != null) { - Tasks.Widgets.TaskListGrid? task_list_grid; - - if (row is Tasks.Widgets.SourceRow) { - var source = ((Tasks.Widgets.SourceRow) row).source; - var source_uid = source.dup_uid (); - - /* Synchronizing the list whenever its selected discovers task changes done on remote (likely to happen when multiple devices are used) */ - Tasks.Application.model.refresh_task_list.begin (source, null, () => { - try { - Tasks.Application.model.refresh_task_list.end (res); - } catch (Error e) { - warning ("Error syncing task list '%s': %s", source.dup_display_name (), e.message); - } - }); - - task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_child_by_name (source_uid); - if (task_list_grid == null) { - task_list_grid = new Tasks.Widgets.TaskListGrid (source); - task_list_grid_stack.add_named (task_list_grid, source_uid); - } - - task_list_grid_stack.set_visible_child_name (source_uid); - Tasks.Application.settings.set_string ("selected-list", source_uid); - ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (Tasks.Application.model.is_remove_task_list_supported (source)); - - } else if (row is Tasks.Widgets.ScheduledRow) { - var scheduled_task_list_grid = (Tasks.Widgets.ScheduledTaskListGrid) task_list_grid_stack.get_child_by_name (SCHEDULED_LIST_UID); - if (scheduled_task_list_grid == null) { - scheduled_task_list_grid = new Tasks.Widgets.ScheduledTaskListGrid (Tasks.Application.model); - task_list_grid_stack.add_named (scheduled_task_list_grid, SCHEDULED_LIST_UID); - } - - task_list_grid_stack.set_visible_child_name (SCHEDULED_LIST_UID); - Tasks.Application.settings.set_string ("selected-list", SCHEDULED_LIST_UID); - ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (false); - } - - if (task_list_grid != null) { - task_list_grid.update_request (); - } - - } else { - ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (false); - var first_row = listbox.get_row_at_index (0); - if (first_row != null) { - listbox.select_row (first_row); - } - } - }); + listbox.row_selected.connect (on_listbox_row_selected); + add_collection_source (registry.ref_builtin_task_list ()); - + var task_list_collections = registry.list_sources (E.SOURCE_EXTENSION_COLLECTION); task_list_collections.foreach ((collection_source) => { add_collection_source (collection_source); }); - + var last_selected_list = Application.settings.get_string ("selected-list"); if (last_selected_list == SCHEDULED_LIST_UID) { @@ -254,10 +203,16 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { add_source (source); if (last_selected_list == "" && default_task_list == source) { + warning ("Selecting source for %s".printf (source.display_name)); + assert (source_rows[source] != null); listbox.select_row (source_rows[source]); + warning ("Done"); } else if (last_selected_list == source.uid) { + warning ("Selecting source for %s".printf (source.display_name)); + assert (source_rows[source] != null); listbox.select_row (source_rows[source]); + warning ("Done"); } } }); @@ -265,6 +220,60 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { }); } + private void on_listbox_row_selected (Gtk.ListBoxRow? row) { + warning ("Selecting row"); + if (row != null) { + Tasks.Widgets.TaskListGrid? task_list_grid = null; + + if (row is Tasks.Widgets.SourceRow) { + var source = ((Tasks.Widgets.SourceRow) row).source; + var source_uid = source.dup_uid (); + + /* Synchronizing the list whenever its selected discovers task changes done on remote (likely to happen when multiple devices are used) */ + Tasks.Application.model.refresh_task_list.begin (source, null, (obj, res) => { + try { + Tasks.Application.model.refresh_task_list.end (res); + } catch (Error e) { + warning ("Error syncing task list '%s': %s", source.dup_display_name (), e.message); + } + }); + + task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_child_by_name (source_uid); + if (task_list_grid == null) { + task_list_grid = new Tasks.Widgets.TaskListGrid (source); + task_list_grid_stack.add_named (task_list_grid, source_uid); + } + + task_list_grid_stack.set_visible_child_name (source_uid); + Tasks.Application.settings.set_string ("selected-list", source_uid); + warning ("What the fuck"); + ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (Tasks.Application.model.is_remove_task_list_supported (source)); + warning ("End it please"); + } else if (row is Tasks.Widgets.ScheduledRow) { + var scheduled_task_list_grid = (Tasks.Widgets.ScheduledTaskListGrid) task_list_grid_stack.get_child_by_name (SCHEDULED_LIST_UID); + if (scheduled_task_list_grid == null) { + scheduled_task_list_grid = new Tasks.Widgets.ScheduledTaskListGrid (Tasks.Application.model); + task_list_grid_stack.add_named (scheduled_task_list_grid, SCHEDULED_LIST_UID); + } + + task_list_grid_stack.set_visible_child_name (SCHEDULED_LIST_UID); + Tasks.Application.settings.set_string ("selected-list", SCHEDULED_LIST_UID); + ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + } + + if (task_list_grid != null) { + task_list_grid.update_request (); + } + + } else { + ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + var first_row = listbox.get_row_at_index (0); + if (first_row != null) { + listbox.select_row (first_row); + } + } + } + private void add_new_list (E.Source collection_source) { var error_dialog_primary_text = _("Creating a new task list failed"); var error_dialog_secondary_text = _("The task list registry may be unavailable or unable to be written to."); @@ -328,7 +337,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { }; unowned Gtk.Widget trash_button = message_dialog.add_button (_("Delete Anyway"), Gtk.ResponseType.YES); - trash_button.get_style_context ().add_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); + trash_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); message_dialog.present (); message_dialog.response.connect ((response_id) => { @@ -422,6 +431,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { debug ("Adding row '%s'", source.dup_display_name ()); if (!source_rows.has_key (source)) { + warning ("Set source_rows for %s".printf (source.display_name)); source_rows[source] = new Tasks.Widgets.SourceRow (source); listbox.append (source_rows[source]); diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index d082126340..fb5128a40c 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -56,9 +56,8 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { } construct { - unowned Gtk.StyleContext style_context = get_style_context (); - style_context.add_class ("editable-label"); - style_context.add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + add_css_class ("editable-label"); + get_style_context ().add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); valign = Gtk.Align.CENTER; @@ -77,7 +76,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { icon_name = "edit-symbolic", tooltip_text = _("Edit…") }; - edit_button.get_style_context ().add_class (Granite.STYLE_CLASS_FLAT); + edit_button.add_css_class (Granite.STYLE_CLASS_FLAT); var button_revealer = new Gtk.Revealer () { valign = Gtk.Align.CENTER, diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index e3c41ca7e7..fc97fd2f7a 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -36,7 +36,7 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { margin_start = 6, margin_end = 6 }; - calendar.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); + calendar.add_css_class (Granite.STYLE_CLASS_BACKGROUND); timepicker = new Granite.TimePicker () { margin_top = 12, diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 63caa35100..9c4607fac1 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -62,17 +62,15 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { // always_show_image = icon_name != null }; - unowned Gtk.StyleContext popover_button_context = popover_button.get_style_context (); - popover_button_context.add_class (Granite.STYLE_CLASS_FLAT); - popover_button_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + popover_button.add_css_class (Granite.STYLE_CLASS_FLAT); + popover_button.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic") { tooltip_text = _("Remove") }; - unowned Gtk.StyleContext delete_button_context = delete_button.get_style_context (); - delete_button_context.add_class (Granite.STYLE_CLASS_FLAT); - delete_button_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + delete_button.add_css_class (Granite.STYLE_CLASS_FLAT); + delete_button.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var delete_button_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT, diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index bc97d35d80..a77a48f1d7 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -36,81 +36,71 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { construct { color_button_blue = new Gtk.CheckButton (); - unowned Gtk.StyleContext color_button_blue_context = color_button_blue.get_style_context (); - color_button_blue_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_blue_context.add_class ("blue"); + color_button_blue.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_blue.add_css_class ("blue"); color_button_mint = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_mint_context = color_button_mint.get_style_context (); - color_button_mint_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_mint_context.add_class ("mint"); + color_button_mint.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_mint.add_css_class ("mint"); color_button_green = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_green_context = color_button_green.get_style_context (); - color_button_green_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_green_context.add_class ("green"); + color_button_green.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_green.add_css_class ("green"); color_button_yellow = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_yellow_context = color_button_yellow.get_style_context (); - color_button_yellow_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_yellow_context.add_class ("yellow"); + color_button_yellow.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_yellow.add_css_class ("yellow"); color_button_orange = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_orange_context = color_button_orange.get_style_context (); - color_button_orange_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_orange_context.add_class ("orange"); + color_button_orange.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_orange.add_css_class ("orange"); color_button_red = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_red_context = color_button_red.get_style_context (); - color_button_red_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_red_context.add_class ("red"); + color_button_red.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_red.add_css_class ("red"); color_button_pink = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_pink_context = color_button_pink.get_style_context (); - color_button_pink_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_pink_context.add_class ("pink"); + color_button_pink.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_pink.add_css_class ("pink"); color_button_purple = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_purple_context = color_button_purple.get_style_context (); - color_button_purple_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_purple_context.add_class ("purple"); + color_button_purple.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_purple.add_css_class ("purple"); color_button_brown = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_brown_context = color_button_brown.get_style_context (); - color_button_brown_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_brown_context.add_class ("brown"); + color_button_brown.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_brown.add_css_class ("brown"); color_button_slate = new Gtk.CheckButton () { group = color_button_blue }; - unowned Gtk.StyleContext color_button_slate_context = color_button_slate.get_style_context (); - color_button_slate_context.add_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_slate_context.add_class ("slate"); + color_button_slate.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_slate.add_css_class ("slate"); color_button_none = new Gtk.CheckButton () { group = color_button_blue @@ -142,11 +132,11 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { MainWindow.ACTION_PREFIX + MainWindow.ACTION_DELETE_SELECTED_LIST ); - var delete_list_menuitem = new Gtk.Button (); - delete_list_menuitem.action_name = delete_list_accel_label.action_name; - delete_list_menuitem.get_child ().destroy (); - delete_list_menuitem.child = delete_list_accel_label; - delete_list_menuitem.get_style_context ().add_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); + var delete_list_menuitem = new Gtk.Button () { + action_name = delete_list_accel_label.action_name, + child = delete_list_accel_label + }; + delete_list_menuitem.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top = 3, diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index 27e5afd27b..57ede29624 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -83,16 +83,14 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { xalign = 0 }; - unowned Gtk.StyleContext scheduled_title_context = scheduled_title.get_style_context (); - scheduled_title_context.add_class (Granite.STYLE_CLASS_H1_LABEL); - scheduled_title_context.add_class (Granite.STYLE_CLASS_ACCENT); + scheduled_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); + scheduled_title.add_css_class (Granite.STYLE_CLASS_ACCENT); var placeholder = new Gtk.Label (_("No Tasks")); placeholder.show (); - unowned Gtk.StyleContext placeholder_context = placeholder.get_style_context (); - placeholder_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); - placeholder_context.add_class (Granite.STYLE_CLASS_H2_LABEL); + placeholder.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); task_list = new Gtk.ListBox () { selection_mode = Gtk.SelectionMode.MULTIPLE, @@ -101,7 +99,7 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { task_list.set_placeholder (placeholder); task_list.set_sort_func (sort_function); task_list.set_header_func (header_function); - task_list.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); + task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); var scrolled_window = new Gtk.ScrolledWindow () { hexpand = true, diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 6b3334195c..d16fa47190 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -43,9 +43,8 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { valign = Gtk.Align.CENTER }; - unowned Gtk.StyleContext source_color_context = source_color.get_style_context (); - source_color_context.add_class ("source-color"); - source_color_context.add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + source_color.add_css_class ("source-color"); + source_color.get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); display_name_label = new Gtk.Label (source.display_name) { halign = Gtk.Align.START, diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index f8a35c1271..130f77f34a 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -43,10 +43,8 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { editable_title = new EditableLabel () { margin_start = 24 }; - - unowned Gtk.StyleContext title_context = editable_title.get_style_context (); - title_context.add_class (Granite.STYLE_CLASS_H1_LABEL); - title_context.add_class (Granite.STYLE_CLASS_ACCENT); + editable_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); + editable_title.add_css_class (Granite.STYLE_CLASS_ACCENT); var list_settings_popover = new Tasks.Widgets.ListSettingsPopover (); @@ -57,22 +55,21 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { popover = list_settings_popover, icon_name = "view-more-symbolic" }; - settings_button.get_style_context ().add_class (Granite.STYLE_CLASS_FLAT); - settings_button.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); + settings_button.add_css_class (Granite.STYLE_CLASS_FLAT); + settings_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); var placeholder = new Gtk.Label (_("No Tasks")); placeholder.show (); - unowned Gtk.StyleContext placeholder_context = placeholder.get_style_context (); - placeholder_context.add_class (Granite.STYLE_CLASS_DIM_LABEL); - placeholder_context.add_class (Granite.STYLE_CLASS_H2_LABEL); + placeholder.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); add_task_list = new Gtk.ListBox () { margin_top = 24, selection_mode = Gtk.SelectionMode.SINGLE, activate_on_single_click = true }; - add_task_list.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); + add_task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); var add_task_row = new Tasks.Widgets.TaskRow.for_source (source); add_task_row.unselect.connect (on_row_unselect); @@ -102,16 +99,16 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { selection_mode = Gtk.SelectionMode.MULTIPLE, activate_on_single_click = true }; + task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); task_list.set_placeholder (placeholder); task_list.set_sort_func (sort_function); - task_list.get_style_context ().add_class (Granite.STYLE_CLASS_BACKGROUND); var scrolled_window = new Gtk.ScrolledWindow () { hexpand = true, vexpand = true, - hscrollbar_policy = Gtk.PolicyType.NEVER + hscrollbar_policy = Gtk.PolicyType.NEVER, + child = task_list }; - scrolled_window.child = task_list; column_spacing = 12; attach (editable_title, 0, 0); @@ -124,43 +121,46 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }); on_show_completed_changed (Application.settings.get_boolean ("show-completed")); - // settings_button.activate.connect (() => { - // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - - // if (settings_button.active) { - // list_settings_popover.source = source; - - // if (win_action_map != null) { - // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); - // } - - // } else if (win_action_map != null) { - // /* - // * We can't immediate disable the action once the popover is closed, - // * because this would lead to the action not beeing executed in case - // * the popover was closed because the user clicked on the action. - // * Therefore we wait a tiny bit using GLib.Idle to allow the action to - // * be executed if needed. - // */ - // GLib.Idle.add (() => { - // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled ( - // add_task_list.get_selected_rows ().length () == 0 && - // task_list.get_selected_rows ().length () == 0 - // ); - // return GLib.Source.REMOVE; - // }); - // } - // }); + settings_button.activate.connect (() => { + unowned var application = (Gtk.Application) GLib.Application.get_default (); + + // TODO: + // error: `Gtk.MenuButton.get_active' is not available in gtk4 4.6.6. Use gtk4 >= 4.10 + // if (settings_button.active) { + if (false) { + list_settings_popover.source = source; + + if (application != null) { + ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); + } + + } else if (application != null) { + /* + * We can't immediate disable the action once the popover is closed, + * because this would lead to the action not being executed in case + * the popover was closed because the user clicked on the action. + * Therefore we wait a tiny bit using GLib.Idle to allow the action to + * be executed if needed. + */ + GLib.Idle.add (() => { + ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled ( + add_task_list.get_selected_rows ().length () == 0 && + task_list.get_selected_rows ().length () == 0 + ); + return GLib.Source.REMOVE; + }); + } + }); add_task_list.row_activated.connect (on_row_activated); task_list.row_activated.connect (on_row_activated); - // editable_title.notify["editing"].connect (() => { - // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - // if (win_action_map != null) { - // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (!editable_title.editing); - // } - // }); + editable_title.notify["editing"].connect (() => { + unowned var application = (Gtk.Application) GLib.Application.get_default (); + if (application != null) { + ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (!editable_title.editing); + } + }); editable_title.changed.connect (() => { Application.model.update_task_list_display_name.begin (source, editable_title.text, (obj, res) => { @@ -221,10 +221,10 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var task_row = (Tasks.Widgets.TaskRow) row; task_row.reveal_child_request (true); - // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - // if (win_action_map != null) { - // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); - // } + unowned var application = (Gtk.Application) GLib.Application.get_default (); + if (application != null) { + ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + } } private void on_row_unselect (Gtk.ListBoxRow row) { @@ -232,12 +232,12 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { ((Gtk.ListBox) row.parent).unselect_row (row); } - // if (add_task_list.get_selected_rows ().length () == 0 && task_list.get_selected_rows ().length () == 0) { - // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - // if (win_action_map != null) { - // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); - // } - // } + if (add_task_list.get_selected_rows ().length () == 0 && task_list.get_selected_rows ().length () == 0) { + unowned var application = (Gtk.Application) GLib.Application.get_default (); + if (application != null) { + ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); + } + } } public void update_request () { diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 8061e34401..5de027f06a 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -49,7 +49,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Gtk.Revealer task_detail_revealer; private Gtk.Revealer task_form_revealer; private Gtk.TextBuffer description_textbuffer; - private unowned Gtk.StyleContext style_context; private static Gtk.CssProvider taskrow_provider; @@ -88,7 +87,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } icon = new Gtk.Image.from_icon_name ("list-add-symbolic"); - icon.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); + icon.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); check = new Gtk.CheckButton () { valign = Gtk.Align.CENTER @@ -102,9 +101,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { summary_entry = new Gtk.Entry (); - unowned Gtk.StyleContext summary_entry_context = summary_entry.get_style_context (); - summary_entry_context.add_class (Granite.STYLE_CLASS_FLAT); - summary_entry_context.add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + summary_entry.add_css_class (Granite.STYLE_CLASS_FLAT); + summary_entry.get_style_context ().add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); due_datetime_popover = new Tasks.Widgets.EntryPopover.DateTime (); @@ -120,13 +118,13 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { }; due_datetime_popover.value_format.connect ((value) => { - due_datetime_popover.get_style_context ().remove_class ("error"); + due_datetime_popover.remove_css_class ("error"); if (value == null) { return null; } var today = new GLib.DateTime.now_local (); if (today.compare (value) > 0 && !completed) { - due_datetime_popover.get_style_context ().add_class ("error"); + due_datetime_popover.add_css_class ("error"); } if (is_gtask) { @@ -203,7 +201,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { lines = 1, ellipsize = Pango.EllipsizeMode.END }; - description_label.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); + description_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); // Should not use a transition that varies the width else label aligning and ellipsizing is incorrect. description_label_revealer = new Gtk.Revealer () { @@ -240,7 +238,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var cancel_button = new Gtk.Button.with_label (_("Cancel")); var save_button = new Gtk.Button.with_label (created ? _("Save Changes") : _("Add Task")); - save_button.get_style_context ().add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); + save_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { baseline_position = Gtk.BaselinePosition.CENTER, @@ -296,16 +294,15 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { margin_start = 12; margin_end = 12; - style_context = get_style_context (); - style_context.add_class (Granite.STYLE_CLASS_ROUNDED); - style_context.add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + add_css_class (Granite.STYLE_CLASS_ROUNDED); + get_style_context ().add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); if (created) { check.show (); state_stack.visible_child = check; var delete_button = new Gtk.Button.with_label (_("Delete Task")); - delete_button.get_style_context ().add_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); + delete_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); button_box.append (delete_button); button_box.append (delete_button); @@ -419,12 +416,12 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { task_details_reveal_request (!value); if (value) { - style_context.add_class ("collapsed"); - style_context.add_class (Granite.STYLE_CLASS_CARD); + add_css_class ("collapsed"); + add_css_class (Granite.STYLE_CLASS_CARD); } else { - style_context.remove_class (Granite.STYLE_CLASS_CARD); - style_context.remove_class ("collapsed"); + remove_css_class (Granite.STYLE_CLASS_CARD); + remove_css_class ("collapsed"); } } @@ -443,10 +440,10 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { completed = false; check.active = completed; summary_entry.text = ""; - summary_entry.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); - summary_entry.get_style_context ().add_class ("add-task"); + summary_entry.remove_css_class (Granite.STYLE_CLASS_DIM_LABEL); + summary_entry.add_css_class ("add-task"); task_detail_revealer.reveal_child = false; - task_detail_revealer.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); + task_detail_revealer.remove_css_class (Granite.STYLE_CLASS_DIM_LABEL); due_datetime_popover_revealer.reveal_child = false; // location_popover_revealer.reveal_child = false; @@ -468,14 +465,14 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } summary_entry.text = ical_task.get_summary () == null ? "" : ical_task.get_summary (); - summary_entry.get_style_context ().remove_class ("add-task"); + summary_entry.remove_css_class ("add-task"); if (completed) { - summary_entry.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); - task_detail_revealer.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); + summary_entry.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + task_detail_revealer.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); } else { - summary_entry.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); - task_detail_revealer.get_style_context ().remove_class (Granite.STYLE_CLASS_DIM_LABEL); + summary_entry.remove_css_class (Granite.STYLE_CLASS_DIM_LABEL); + task_detail_revealer.remove_css_class (Granite.STYLE_CLASS_DIM_LABEL); } if (ical_task.get_due ().is_null_time ()) { From d91fe4516fbe7b896793efe975f8768a5a7d50c4 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 21:36:29 +0900 Subject: [PATCH 07/86] Fix terminal warnings --- src/MainWindow.vala | 11 ++--------- src/TaskModel.vala | 11 +++++++---- src/Widgets/ScheduledTaskListGrid.vala | 16 ++++++++-------- src/Widgets/TaskListGrid.vala | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 177a997cc6..2bd3076942 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -203,16 +203,12 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { add_source (source); if (last_selected_list == "" && default_task_list == source) { - warning ("Selecting source for %s".printf (source.display_name)); assert (source_rows[source] != null); listbox.select_row (source_rows[source]); - warning ("Done"); } else if (last_selected_list == source.uid) { - warning ("Selecting source for %s".printf (source.display_name)); assert (source_rows[source] != null); listbox.select_row (source_rows[source]); - warning ("Done"); } } }); @@ -221,7 +217,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } private void on_listbox_row_selected (Gtk.ListBoxRow? row) { - warning ("Selecting row"); if (row != null) { Tasks.Widgets.TaskListGrid? task_list_grid = null; @@ -238,7 +233,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } }); - task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_child_by_name (source_uid); + task_list_grid = (Tasks.Widgets.TaskListGrid?) task_list_grid_stack.get_child_by_name (source_uid); if (task_list_grid == null) { task_list_grid = new Tasks.Widgets.TaskListGrid (source); task_list_grid_stack.add_named (task_list_grid, source_uid); @@ -246,9 +241,8 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { task_list_grid_stack.set_visible_child_name (source_uid); Tasks.Application.settings.set_string ("selected-list", source_uid); - warning ("What the fuck"); ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (Tasks.Application.model.is_remove_task_list_supported (source)); - warning ("End it please"); + } else if (row is Tasks.Widgets.ScheduledRow) { var scheduled_task_list_grid = (Tasks.Widgets.ScheduledTaskListGrid) task_list_grid_stack.get_child_by_name (SCHEDULED_LIST_UID); if (scheduled_task_list_grid == null) { @@ -431,7 +425,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { debug ("Adding row '%s'", source.dup_display_name ()); if (!source_rows.has_key (source)) { - warning ("Set source_rows for %s".printf (source.display_name)); source_rows[source] = new Tasks.Widgets.SourceRow (source); listbox.append (source_rows[source]); diff --git a/src/TaskModel.vala b/src/TaskModel.vala index 41e619ebe8..0cefb44381 100644 --- a/src/TaskModel.vala +++ b/src/TaskModel.vala @@ -36,7 +36,7 @@ public class Tasks.TaskModel : Object { public delegate void TasksRemovedFunc (SList cids); private Gee.Future registry; - private NetworkMonitor network_monitor; + // private NetworkMonitor network_monitor; private HashTable task_list_client; private HashTable> task_list_client_views; @@ -141,7 +141,7 @@ public class Tasks.TaskModel : Object { var promise = new Gee.Promise (); registry = promise.future; yield init_registry (promise); - network_monitor.network_changed.connect (network_changed); + // network_monitor.network_changed.connect (network_changed); } private async void init_registry (Gee.Promise promise) { @@ -240,15 +240,18 @@ public class Tasks.TaskModel : Object { } private async bool refresh_collection (E.Source collection_source, Cancellable? cancellable = null) throws Error { - if (network_monitor.network_available && registry.ready) { + // if (network_monitor.network_available && registry.ready) { + if (registry.ready) { debug ("Scheduling collection refresh '%s'…", collection_source.dup_display_name ()); return yield registry.value.refresh_backend (collection_source.dup_uid (), cancellable); } + return false; } public async bool refresh_task_list (E.Source task_list, Cancellable? cancellable = null) throws Error { - if (network_monitor.network_available && task_list_client.contains (task_list.dup_uid ())) { + // if (network_monitor.network_available && task_list_client.contains (task_list.dup_uid ())) { + if (task_list_client.contains (task_list.dup_uid ())) { var client = task_list_client.get (task_list.dup_uid ()); if (client.check_refresh_supported ()) { diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index 57ede29624..b3192b2fef 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -159,11 +159,10 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { var task_row = (Tasks.Widgets.TaskRow) row; task_row.reveal_child_request (true); - // ((Gtk.Window) get_root ()).get_application ().lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST).set_enabled (false); - // unowned GLib.ActionMap win_action_map = (GLib.ActionMap) get_action_group (MainWindow.ACTION_GROUP_PREFIX); - // if (win_action_map != null) { - // ((SimpleAction) win_action_map.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); - // } + unowned var application = (Gtk.Application) GLib.Application.get_default (); + if (application != null) { + ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + } } private void on_row_unselect (Gtk.ListBoxRow row) { @@ -201,9 +200,10 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { } var due_date_time = Tasks.Util.ical_to_date_time_local (comp.get_due ()); - var header_label = new Granite.HeaderLabel (Tasks.Util.get_relative_date (due_date_time)); - // header_label.ellipsize = Pango.EllipsizeMode.MIDDLE; - header_label.margin_start = 6; + var header_label = new Granite.HeaderLabel (Tasks.Util.get_relative_date (due_date_time)) { + margin_start = 6 + // ellipsize = Pango.EllipsizeMode.MIDDLE + }; row.set_header (header_label); } diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 130f77f34a..a9e467a28e 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -32,8 +32,8 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } construct { - E.SourceRegistry? registry = null; try { + E.SourceRegistry registry; registry = Application.model.get_registry_sync (); is_gtasks = Application.model.get_collection_backend_name (source, registry) == "google"; } catch (Error e) { From 5d957ae9108e621cc368256762e3bc7ad4fba838 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 21:44:23 +0900 Subject: [PATCH 08/86] Fix warning --- src/Widgets/TaskRow.vala | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 5de027f06a..73b7ca370a 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -100,7 +100,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { state_stack.add_child (check); summary_entry = new Gtk.Entry (); - summary_entry.add_css_class (Granite.STYLE_CLASS_FLAT); summary_entry.get_style_context ().add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -242,8 +241,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { baseline_position = Gtk.BaselinePosition.CENTER, - margin_top = 12, - spacing = 6 + margin_top = 12 }; // button_box.set_layout (Gtk.ButtonBoxStyle.END); button_box.append (cancel_button); @@ -304,7 +302,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var delete_button = new Gtk.Button.with_label (_("Delete Task")); delete_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); - button_box.append (delete_button); button_box.append (delete_button); delete_button.clicked.connect (() => { From bd053f7964255671cf245ead71efb5515d44efe7 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 22:10:20 +0900 Subject: [PATCH 09/86] FIx SimpleAction error --- src/Widgets/EditableLabel.vala | 1 + src/Widgets/ScheduledTaskListGrid.vala | 6 ++--- src/Widgets/TaskListGrid.vala | 32 ++++++++++++++------------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index fb5128a40c..508ad7e5e1 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -141,6 +141,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { } ~EditableLabel () { + warning ("Destroying"); get_last_child ().unparent (); } } diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index b3192b2fef..de0dfef425 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -159,9 +159,9 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { var task_row = (Tasks.Widgets.TaskRow) row; task_row.reveal_child_request (true); - unowned var application = (Gtk.Application) GLib.Application.get_default (); - if (application != null) { - ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + unowned var main_window = (MainWindow) get_root (); + if (main_window != null) { + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); } } diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index a9e467a28e..168feded23 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -41,7 +41,8 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } editable_title = new EditableLabel () { - margin_start = 24 + margin_start = 24, + hexpand = true }; editable_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); editable_title.add_css_class (Granite.STYLE_CLASS_ACCENT); @@ -51,6 +52,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var settings_button = new Gtk.MenuButton () { margin_end = 24, valign = Gtk.Align.CENTER, + hexpand = false, tooltip_text = _("Edit Name and Appearance"), popover = list_settings_popover, icon_name = "view-more-symbolic" @@ -122,7 +124,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { on_show_completed_changed (Application.settings.get_boolean ("show-completed")); settings_button.activate.connect (() => { - unowned var application = (Gtk.Application) GLib.Application.get_default (); + unowned var main_window = (MainWindow) get_root (); // TODO: // error: `Gtk.MenuButton.get_active' is not available in gtk4 4.6.6. Use gtk4 >= 4.10 @@ -130,11 +132,11 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { if (false) { list_settings_popover.source = source; - if (application != null) { - ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); + if (main_window != null) { + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); } - } else if (application != null) { + } else if (main_window != null) { /* * We can't immediate disable the action once the popover is closed, * because this would lead to the action not being executed in case @@ -143,7 +145,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { * be executed if needed. */ GLib.Idle.add (() => { - ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled ( + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled ( add_task_list.get_selected_rows ().length () == 0 && task_list.get_selected_rows ().length () == 0 ); @@ -156,9 +158,9 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { task_list.row_activated.connect (on_row_activated); editable_title.notify["editing"].connect (() => { - unowned var application = (Gtk.Application) GLib.Application.get_default (); - if (application != null) { - ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (!editable_title.editing); + unowned var main_window = (MainWindow) get_root (); + if (main_window != null) { + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (!editable_title.editing); } }); @@ -221,9 +223,9 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var task_row = (Tasks.Widgets.TaskRow) row; task_row.reveal_child_request (true); - unowned var application = (Gtk.Application) GLib.Application.get_default (); - if (application != null) { - ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); + unowned var main_window = (MainWindow) get_root (); + if (main_window != null) { + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (false); } } @@ -233,9 +235,9 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } if (add_task_list.get_selected_rows ().length () == 0 && task_list.get_selected_rows ().length () == 0) { - unowned var application = (Gtk.Application) GLib.Application.get_default (); - if (application != null) { - ((SimpleAction) application.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); + unowned var main_window = (MainWindow) get_root (); + if (main_window != null) { + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).set_enabled (true); } } } From 7834c76b0d754bb0606fd86ed14b4a2bd8f1be12 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 22:10:49 +0900 Subject: [PATCH 10/86] Remove debug message --- src/Widgets/EditableLabel.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index 508ad7e5e1..fb5128a40c 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -141,7 +141,6 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { } ~EditableLabel () { - warning ("Destroying"); get_last_child ().unparent (); } } From 224c4dee7e94b82f51a35b9020abb57048522390 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 4 Jun 2023 22:42:30 +0900 Subject: [PATCH 11/86] Fix segmentation fault --- src/MainWindow.vala | 2 +- src/Widgets/EditableLabel.vala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 2bd3076942..fbbaa5a10d 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -233,7 +233,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } }); - task_list_grid = (Tasks.Widgets.TaskListGrid?) task_list_grid_stack.get_child_by_name (source_uid); + task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_child_by_name (source_uid); if (task_list_grid == null) { task_list_grid = new Tasks.Widgets.TaskListGrid (source); task_list_grid_stack.add_named (task_list_grid, source_uid); diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index fb5128a40c..4c7567da87 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -29,7 +29,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { private Gtk.Stack stack; private Gtk.Box box; - public string text { get; set; } + public string text { get; set; default = ""; } public bool editing { get { return stack.visible_child == entry; } From 5b2fcc1f5b8a3139ac75377b7eae6f7a23c9c027 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 14:31:42 +0900 Subject: [PATCH 12/86] Fix focus issue --- src/Widgets/TaskRow.vala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 73b7ca370a..8f6e0180ac 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -73,7 +73,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } construct { - can_focus = false; created = calcomponent_created (task); // GTasks tasks only have date on due time, so only show the date @@ -314,6 +313,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { // build_drag_and_drop (); var key_controller = new Gtk.EventControllerKey (); + add_controller (key_controller); check.toggled.connect (() => { if (task == null) { @@ -329,9 +329,11 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { end_editing (); }); - // summary_entry.grab_focus.connect (() => { - // activate (); - // }); + var summary_entry_focus_controller = new Gtk.EventControllerFocus (); + summary_entry.add_controller (summary_entry_focus_controller); + summary_entry_focus_controller.enter.connect (() => { + activate (); + }); cancel_button.clicked.connect (() => { reset_form (); From 0dfbd7f00030d1f232bd317b764f3186f386c1f3 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 15:05:06 +0900 Subject: [PATCH 13/86] Try to fix button --- src/MainWindow.vala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index fbbaa5a10d..8b15a3f1e0 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -102,12 +102,14 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { }; var add_tasklist_button = new Gtk.MenuButton () { - label = _("Add Task List…"), - icon_name = "list-add-symbolic", - // always_show_image = true, popover = add_tasklist_popover }; + var add_tasklist_button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + add_tasklist_button_box.append (new Gtk.Image.from_icon_name ("list-add-symbolic")); + add_tasklist_button_box.append (new Gtk.Label (_("Add Task List…"))); + add_tasklist_button.child = add_tasklist_button_box; + var actionbar = new Gtk.ActionBar (); actionbar.pack_start (add_tasklist_button); actionbar.add_css_class (Granite.STYLE_CLASS_FLAT); From 6ab5a0e77ad3ac4025389175f1110ddbe63a7764 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 15:20:29 +0900 Subject: [PATCH 14/86] Improve DateTime widget appearance --- src/MainWindow.vala | 3 +- src/Widgets/EntryPopover/DateTime.vala | 18 +++---- src/Widgets/EntryPopover/Generic.vala | 74 +++++++++++++------------- src/Widgets/TaskListGrid.vala | 2 +- 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8b15a3f1e0..a11e54f340 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -102,7 +102,8 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { }; var add_tasklist_button = new Gtk.MenuButton () { - popover = add_tasklist_popover + popover = add_tasklist_popover, + direction = Gtk.ArrowType.UP }; var add_tasklist_button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index fc97fd2f7a..6d65d44d05 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -34,9 +34,9 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { margin_top = 6, margin_bottom = 6, margin_start = 6, - margin_end = 6 + margin_end = 6, + css_classes = { Granite.STYLE_CLASS_BACKGROUND } }; - calendar.add_css_class (Granite.STYLE_CLASS_BACKGROUND); timepicker = new Granite.TimePicker () { margin_top = 12, @@ -55,12 +55,12 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { margin_top = 3 }; - var today_button = new Gtk.Button () { - label = _("Today") + var today_button = new Gtk.Button.with_label (_("Today")) { + css_classes = { Granite.STYLE_CLASS_FLAT } }; var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - margin_top= 3 + margin_top = 3 }; box.append (today_button); box.append (today_separator); @@ -90,17 +90,11 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { } calendar.select_day (selected_datetime); - // calendar.select_month (selected_datetime.get_month () - 1, selected_datetime.get_year ()); - // calendar.select_day (selected_datetime.get_day_of_month ()); timepicker.time = selected_datetime; } private void on_today_button_clicked () { - var now_local = new GLib.DateTime.now_local (); - - calendar.select_day (now_local); - // calendar.select_month (now_local.get_month () - 1, now_local.get_year ()); - // calendar.select_day (now_local.get_day_of_month ()); + calendar.select_day (new GLib.DateTime.now_local ()); } private void on_calendar_day_selected () { diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 9c4607fac1..c372da14cf 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -1,5 +1,5 @@ /* -* Copyright 2021 elementary, Inc. (https://elementary.io) +* Copyright 2021-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -43,33 +43,33 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { static construct { set_layout_manager_type (typeof (Gtk.BinLayout)); + style_provider = new Gtk.CssProvider (); style_provider.load_from_resource ("io/elementary/tasks/EntryPopover.css"); } construct { - var motion_controller = new Gtk.EventControllerMotion (); - add_controller (motion_controller); - popover = new Gtk.Popover () { child = popover_button }; + var popover_button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + if (icon_name != null) { + popover_button_box.append (new Gtk.Image.from_icon_name (icon_name)); + } + popover_button_box.append (new Gtk.Label (placeholder)); + popover_button = new Gtk.MenuButton () { - label = placeholder, popover = popover, - icon_name = icon_name, - // always_show_image = icon_name != null + child = popover_button_box, + css_classes = { Granite.STYLE_CLASS_FLAT } }; - - popover_button.add_css_class (Granite.STYLE_CLASS_FLAT); popover_button.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic") { - tooltip_text = _("Remove") + tooltip_text = _("Remove"), + css_classes = { Granite.STYLE_CLASS_FLAT } }; - - delete_button.add_css_class (Granite.STYLE_CLASS_FLAT); delete_button.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var delete_button_revealer = new Gtk.Revealer () { @@ -79,11 +79,32 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { }; var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + button_box.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); button_box.append (popover_button); button_box.append (delete_button_revealer); - button_box.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + button_box.set_parent (this); + + popover_button.activate.connect (() => { + if (delete_button_revealer.reveal_child) { + delete_button_revealer.reveal_child = false; + } + }); - button_box.set_parent (this); // ? + popover.show.connect (() => { + GLib.Idle.add (() => { + value_on_popover_show = value; + return GLib.Source.REMOVE; + }); + }); + + popover.closed.connect (() => { + GLib.Idle.add (() => { + if (value != value_on_popover_show) { + value_changed (value); + } + return GLib.Source.REMOVE; + }); + }); delete_button.clicked.connect (() => { var value_has_changed = value != null; @@ -93,12 +114,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { } }); - popover_button.activate.connect (() => { - if (delete_button_revealer.reveal_child) { - delete_button_revealer.reveal_child = false; - } - }); - notify["value"].connect (() => { var value_formatted = value_format (value); if (value_formatted == null) { @@ -113,6 +128,9 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { } }); + var motion_controller = new Gtk.EventControllerMotion (); + add_controller (motion_controller); + motion_controller.enter.connect ((x, y) => { if (value_format (value) != null) { delete_button_revealer.reveal_child = true; @@ -124,22 +142,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { delete_button_revealer.reveal_child = false; } }); - - popover.show.connect (() => { - GLib.Idle.add (() => { - value_on_popover_show = value; - return GLib.Source.REMOVE; - }); - }); - - popover.closed.connect (() => { - GLib.Idle.add (() => { - if (value != value_on_popover_show) { - value_changed (value); - } - return GLib.Source.REMOVE; - }); - }); } ~Generic () { diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 168feded23..c8e8d91841 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -98,7 +98,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { add_task_list.append (add_task_row); task_list = new Gtk.ListBox () { - selection_mode = Gtk.SelectionMode.MULTIPLE, + selection_mode = Gtk.SelectionMode.SINGLE, activate_on_single_click = true }; task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); From 4b208ac2ace5766c52e41aaf3288eb79e74c4646 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 15:24:25 +0900 Subject: [PATCH 15/86] Fix calendar icon --- src/Widgets/EntryPopover/Generic.vala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index c372da14cf..18cbf29695 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -28,6 +28,7 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { private Gtk.MenuButton popover_button; private static Gtk.CssProvider style_provider; + private Gtk.Label label; private T value_on_popover_show; protected Generic (string placeholder, string? icon_name = null) { @@ -53,11 +54,13 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { child = popover_button }; + label = new Gtk.Label (placeholder); + var popover_button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); if (icon_name != null) { popover_button_box.append (new Gtk.Image.from_icon_name (icon_name)); } - popover_button_box.append (new Gtk.Label (placeholder)); + popover_button_box.append (label); popover_button = new Gtk.MenuButton () { popover = popover, @@ -117,14 +120,14 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { notify["value"].connect (() => { var value_formatted = value_format (value); if (value_formatted == null) { - popover_button.label = placeholder; + label.label = placeholder; if (delete_button_revealer.reveal_child) { delete_button_revealer.reveal_child = false; } } else { - popover_button.label = value_formatted; + label.label = value_formatted; } }); From a8a7caa8a7352b155a0228381a06cd1974819905 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 15:29:16 +0900 Subject: [PATCH 16/86] Calendar widget again --- src/Widgets/EntryPopover/DateTime.vala | 3 +-- src/Widgets/EntryPopover/Generic.vala | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index 6d65d44d05..4733d3bb36 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -34,8 +34,7 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { margin_top = 6, margin_bottom = 6, margin_start = 6, - margin_end = 6, - css_classes = { Granite.STYLE_CLASS_BACKGROUND } + margin_end = 6 }; timepicker = new Granite.TimePicker () { diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 18cbf29695..cf9e1c5a04 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -51,7 +51,8 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { construct { popover = new Gtk.Popover () { - child = popover_button + child = popover_button, + autohide = true }; label = new Gtk.Label (placeholder); From 3aff64bc57f4185822864ad50164a88293d9bfca Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 15:40:37 +0900 Subject: [PATCH 17/86] Compile Location.vala --- meson.build | 2 +- src/Widgets/EntryPopover/Location.vala | 382 ++++++++++++------------- src/Widgets/TaskRow.vala | 22 +- 3 files changed, 203 insertions(+), 203 deletions(-) diff --git a/meson.build b/meson.build index 338d93451f..c5fa360f26 100644 --- a/meson.build +++ b/meson.build @@ -65,7 +65,7 @@ executable( 'src/Widgets/EditableLabel.vala', 'src/Widgets/EntryPopover/DateTime.vala', 'src/Widgets/EntryPopover/Generic.vala', - # 'src/Widgets/EntryPopover/Location.vala', + 'src/Widgets/EntryPopover/Location.vala', 'src/Widgets/ScheduledRow.vala', 'src/Widgets/SourceRow.vala', 'src/Widgets/ScheduledTaskListGrid.vala', diff --git a/src/Widgets/EntryPopover/Location.vala b/src/Widgets/EntryPopover/Location.vala index 343c3e646e..837cb37819 100644 --- a/src/Widgets/EntryPopover/Location.vala +++ b/src/Widgets/EntryPopover/Location.vala @@ -18,11 +18,11 @@ */ public class Tasks.Widgets.EntryPopover.Location : Generic { - private GtkChamplain.Embed map_embed; + // private GtkChamplain.Embed map_embed; private Gtk.SearchEntry search_entry; private GLib.Cancellable search_cancellable; - private Granite.Widgets.ModeButton location_mode; - private Marker point; + // private Granite.Widgets.ModeButton location_mode; + // private Marker point; public Location () { @@ -33,28 +33,28 @@ public class Tasks.Widgets.EntryPopover.Location : Generic { } construct { - map_embed = new GtkChamplain.Embed () { - height_request = 140, - width_request = 260 - }; + // map_embed = new GtkChamplain.Embed () { + // height_request = 140, + // width_request = 260 + // }; - point = new Marker (); + // point = new Marker (); - var marker_layer = new Champlain.MarkerLayer.full (Champlain.SelectionMode.SINGLE); - marker_layer.add_marker (point); + // var marker_layer = new Champlain.MarkerLayer.full (Champlain.SelectionMode.SINGLE); + // marker_layer.add_marker (point); - var map_view = map_embed.champlain_view; - map_view.zoom_level = 10; - map_view.goto_animation_duration = 500; - map_view.add_layer (marker_layer); - map_view.center_on (point.latitude, point.longitude); + // var map_view = map_embed.champlain_view; + // map_view.zoom_level = 10; + // map_view.goto_animation_duration = 500; + // map_view.add_layer (marker_layer); + // map_view.center_on (point.latitude, point.longitude); - var map_frame = new Gtk.Frame (null); - map_frame.add (map_embed); + // var map_frame = new Gtk.Frame (null); + // map_frame.add (map_embed); - location_mode = new Granite.Widgets.ModeButton (); - location_mode.append_text (_("Arriving")); - location_mode.append_text (_("Leaving")); + // location_mode = new Granite.Widgets.ModeButton (); + // location_mode.append_text (_("Arriving")); + // location_mode.append_text (_("Leaving")); search_entry = new Gtk.SearchEntry () { placeholder_text = _("John Smith OR Example St."), @@ -69,180 +69,180 @@ public class Tasks.Widgets.EntryPopover.Location : Generic { }; box.append (search_entry); - box.append (location_mode); - box.append (map_frame); - - popover.add (box); - popover.show.connect (on_popover_show); + // box.append (location_mode); + // box.append (map_frame); - notify["value"].connect (on_value_changed); + popover.child = box; + // popover.show.connect (on_popover_show); - search_entry.activate.connect (on_search_entry_activate); - location_mode.mode_changed.connect (on_location_mode_changed); - } + // notify["value"].connect (on_value_changed); - private void on_popover_show () { - search_entry.text = (value == null ? "" : value.postal_address); - - if (search_entry.text != null && search_entry.text.strip ().length > 0) { - search_location.begin (search_entry.text); - } else { - // Use geoclue to find approximate location - discover_current_location.begin (); - } - } - - private void on_value_changed () { - if (value == null) { - return; - } - - var value_has_postal_address = value.postal_address != null && value.postal_address.strip ().length > 0; - if (value_has_postal_address && search_entry.text != value.postal_address) { - search_entry.text = value.postal_address; - } - - switch (value.proximity) { - case Tasks.LocationProximity.ARRIVE: - if (location_mode.selected != 0) { - location_mode.selected = 0; - } - break; - - default: - if (location_mode.selected != 1) { - location_mode.selected = 1; - } - break; - } - - bool need_relocation = true; - if (value.latitude >= Champlain.MIN_LATITUDE && value.longitude >= Champlain.MIN_LONGITUDE && - value.latitude <= Champlain.MAX_LATITUDE && value.longitude <= Champlain.MAX_LONGITUDE) { - - point.latitude = value.latitude; - point.longitude = value.longitude; - - need_relocation = (value.latitude == 0 && value.longitude == 0); - } - - if (need_relocation == true) { - if (value_has_postal_address) { - search_location.begin (value.postal_address); - } else { - // Use geoclue to find approximate location - discover_current_location.begin (); - } - } - } - - private void on_search_entry_activate () { - value = Tasks.Location () { - postal_address = search_entry.text, - display_name = search_entry.text, - longitude = 0, - latitude = 0, - accuracy = (value == null ? Geocode.LocationAccuracy.UNKNOWN : value.accuracy), - proximity = (value == null ? Tasks.LocationProximity.DEPART : value.proximity) - }; + // search_entry.activate.connect (on_search_entry_activate); + // location_mode.mode_changed.connect (on_location_mode_changed); } - private void on_location_mode_changed () { - var proximity = (value == null ? Tasks.LocationProximity.DEPART : value.proximity); - - switch (location_mode.selected) { - case 0: proximity = Tasks.LocationProximity.ARRIVE; break; - case 1: proximity = Tasks.LocationProximity.DEPART; break; - default: break; - } - - value = Tasks.Location () { - postal_address = (value == null ? search_entry.text : value.postal_address), - display_name = (value == null ? search_entry.text : value.display_name), - longitude = (value == null ? 0 : value.longitude), - latitude = (value == null ? 0 : value.latitude), - accuracy = (value == null ? Geocode.LocationAccuracy.UNKNOWN : value.accuracy), - proximity = proximity - }; - } - - private async void search_location (string location) { - if (search_cancellable != null) { - search_cancellable.cancel (); - } - search_cancellable = new GLib.Cancellable (); - - var forward = new Geocode.Forward.for_string (location); - try { - forward.set_answer_count (1); - var places = yield forward.search_async (search_cancellable); - foreach (var place in places) { - point.latitude = place.location.latitude; - point.longitude = place.location.longitude; - - if (value != null) { - value.latitude = place.location.latitude; - value.longitude = place.location.longitude; - } - - Idle.add (() => { - if (search_cancellable.is_cancelled () == false) { - map_embed.champlain_view.go_to (point.latitude, point.longitude); - } - return GLib.Source.REMOVE; - }); - } - - search_entry.has_focus = true; - } catch (Error error) { - debug (error.message); - } - } - - private async void discover_current_location () { - if (search_cancellable != null) { - search_cancellable.cancel (); - } - search_cancellable = new GLib.Cancellable (); - - try { - var simple = yield new GClue.Simple ("io.elementary.tasks", GClue.AccuracyLevel.CITY, null); - - point.latitude = simple.location.latitude; - point.longitude = simple.location.longitude; - - Idle.add (() => { - if (search_cancellable.is_cancelled () == false) { - map_embed.champlain_view.go_to (point.latitude, point.longitude); - } - return GLib.Source.REMOVE; - }); - - } catch (Error e) { - warning ("Failed to connect to GeoClue2 service: %s", e.message); - // Fallback to timezone location - search_location.begin (ECal.util_get_system_timezone_location ()); - } - } - - private class Marker : Champlain.Marker { - public Marker () { - try { - weak Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default (); - var pixbuf = icon_theme.load_icon ("location-marker", 32, Gtk.IconLookupFlags.GENERIC_FALLBACK); - Clutter.Image image = new Clutter.Image (); - image.set_data (pixbuf.get_pixels (), - pixbuf.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888, - pixbuf.width, - pixbuf.height, - pixbuf.rowstride); - content = image; - set_size (pixbuf.width, pixbuf.height); - translation_x = -pixbuf.width / 2; - translation_y = -pixbuf.height; - } catch (Error e) { - critical (e.message); - } - } - } + // private void on_popover_show () { + // search_entry.text = (value == null ? "" : value.postal_address); + + // if (search_entry.text != null && search_entry.text.strip ().length > 0) { + // search_location.begin (search_entry.text); + // } else { + // // Use geoclue to find approximate location + // discover_current_location.begin (); + // } + // } + + // private void on_value_changed () { + // if (value == null) { + // return; + // } + + // var value_has_postal_address = value.postal_address != null && value.postal_address.strip ().length > 0; + // if (value_has_postal_address && search_entry.text != value.postal_address) { + // search_entry.text = value.postal_address; + // } + + // switch (value.proximity) { + // case Tasks.LocationProximity.ARRIVE: + // if (location_mode.selected != 0) { + // location_mode.selected = 0; + // } + // break; + + // default: + // if (location_mode.selected != 1) { + // location_mode.selected = 1; + // } + // break; + // } + + // bool need_relocation = true; + // if (value.latitude >= Champlain.MIN_LATITUDE && value.longitude >= Champlain.MIN_LONGITUDE && + // value.latitude <= Champlain.MAX_LATITUDE && value.longitude <= Champlain.MAX_LONGITUDE) { + + // point.latitude = value.latitude; + // point.longitude = value.longitude; + + // need_relocation = (value.latitude == 0 && value.longitude == 0); + // } + + // if (need_relocation == true) { + // if (value_has_postal_address) { + // search_location.begin (value.postal_address); + // } else { + // // Use geoclue to find approximate location + // discover_current_location.begin (); + // } + // } + // } + + // private void on_search_entry_activate () { + // value = Tasks.Location () { + // postal_address = search_entry.text, + // display_name = search_entry.text, + // longitude = 0, + // latitude = 0, + // accuracy = (value == null ? Geocode.LocationAccuracy.UNKNOWN : value.accuracy), + // proximity = (value == null ? Tasks.LocationProximity.DEPART : value.proximity) + // }; + // } + + // private void on_location_mode_changed () { + // var proximity = (value == null ? Tasks.LocationProximity.DEPART : value.proximity); + + // switch (location_mode.selected) { + // case 0: proximity = Tasks.LocationProximity.ARRIVE; break; + // case 1: proximity = Tasks.LocationProximity.DEPART; break; + // default: break; + // } + + // value = Tasks.Location () { + // postal_address = (value == null ? search_entry.text : value.postal_address), + // display_name = (value == null ? search_entry.text : value.display_name), + // longitude = (value == null ? 0 : value.longitude), + // latitude = (value == null ? 0 : value.latitude), + // accuracy = (value == null ? Geocode.LocationAccuracy.UNKNOWN : value.accuracy), + // proximity = proximity + // }; + // } + + // private async void search_location (string location) { + // if (search_cancellable != null) { + // search_cancellable.cancel (); + // } + // search_cancellable = new GLib.Cancellable (); + + // var forward = new Geocode.Forward.for_string (location); + // try { + // forward.set_answer_count (1); + // var places = yield forward.search_async (search_cancellable); + // foreach (var place in places) { + // point.latitude = place.location.latitude; + // point.longitude = place.location.longitude; + + // if (value != null) { + // value.latitude = place.location.latitude; + // value.longitude = place.location.longitude; + // } + + // Idle.add (() => { + // if (search_cancellable.is_cancelled () == false) { + // map_embed.champlain_view.go_to (point.latitude, point.longitude); + // } + // return GLib.Source.REMOVE; + // }); + // } + + // search_entry.has_focus = true; + // } catch (Error error) { + // debug (error.message); + // } + // } + + // private async void discover_current_location () { + // if (search_cancellable != null) { + // search_cancellable.cancel (); + // } + // search_cancellable = new GLib.Cancellable (); + + // try { + // var simple = yield new GClue.Simple ("io.elementary.tasks", GClue.AccuracyLevel.CITY, null); + + // point.latitude = simple.location.latitude; + // point.longitude = simple.location.longitude; + + // Idle.add (() => { + // if (search_cancellable.is_cancelled () == false) { + // map_embed.champlain_view.go_to (point.latitude, point.longitude); + // } + // return GLib.Source.REMOVE; + // }); + + // } catch (Error e) { + // warning ("Failed to connect to GeoClue2 service: %s", e.message); + // // Fallback to timezone location + // search_location.begin (ECal.util_get_system_timezone_location ()); + // } + // } + + // private class Marker : Champlain.Marker { + // public Marker () { + // try { + // weak Gtk.IconTheme icon_theme = Gtk.IconTheme.get_default (); + // var pixbuf = icon_theme.load_icon ("location-marker", 32, Gtk.IconLookupFlags.GENERIC_FALLBACK); + // Clutter.Image image = new Clutter.Image (); + // image.set_data (pixbuf.get_pixels (), + // pixbuf.has_alpha ? Cogl.PixelFormat.RGBA_8888 : Cogl.PixelFormat.RGB_888, + // pixbuf.width, + // pixbuf.height, + // pixbuf.rowstride); + // content = image; + // set_size (pixbuf.width, pixbuf.height); + // translation_x = -pixbuf.width / 2; + // translation_y = -pixbuf.height; + // } catch (Error e) { + // critical (e.message); + // } + // } + // } } diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 8f6e0180ac..4104aa65ed 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -35,8 +35,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Tasks.Widgets.EntryPopover.DateTime due_datetime_popover; private Gtk.Revealer due_datetime_popover_revealer; - // private Tasks.Widgets.EntryPopover.Location location_popover; - // private Gtk.Revealer location_popover_revealer; + private Tasks.Widgets.EntryPopover.Location location_popover; + private Gtk.Revealer location_popover_revealer; // private Gtk.EventBox event_box; private Gtk.Stack state_stack; @@ -158,14 +158,14 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } }); - // location_popover = new Tasks.Widgets.EntryPopover.Location (); + location_popover = new Tasks.Widgets.EntryPopover.Location (); - // location_popover_revealer = new Gtk.Revealer () { - // margin_end = 6, - // reveal_child = false, - // transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT - // }; - // location_popover_revealer.add (location_popover); + location_popover_revealer = new Gtk.Revealer () { + margin_end = 6, + reveal_child = false, + transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT, + child = location_popover + }; // location_popover.value_format.connect ((value) => { // if (value == null) { @@ -208,9 +208,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { child = description_label }; - var task_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + var task_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 3); task_box.append (due_datetime_popover_revealer); - // task_box.append (location_popover_revealer); + task_box.append (location_popover_revealer); task_box.append (description_label_revealer); task_detail_revealer = new Gtk.Revealer () { From f4279fa87db310dc839e5c1d1b8feef35201e3b8 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 15:49:09 +0900 Subject: [PATCH 18/86] Show location icon --- src/MainWindow.vala | 32 ++++++++------- src/Widgets/TaskListGrid.vala | 28 ++++++------- src/Widgets/TaskRow.vala | 74 +++++++++++++++++------------------ 3 files changed, 66 insertions(+), 68 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index a11e54f340..0f296ce3c5 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -101,38 +101,40 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { child = add_tasklist_box }; - var add_tasklist_button = new Gtk.MenuButton () { - popover = add_tasklist_popover, - direction = Gtk.ArrowType.UP - }; - var add_tasklist_button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); add_tasklist_button_box.append (new Gtk.Image.from_icon_name ("list-add-symbolic")); add_tasklist_button_box.append (new Gtk.Label (_("Add Task List…"))); - add_tasklist_button.child = add_tasklist_button_box; - var actionbar = new Gtk.ActionBar (); + var add_tasklist_button = new Gtk.MenuButton () { + popover = add_tasklist_popover, + direction = Gtk.ArrowType.UP, + child = add_tasklist_button_box + }; + + var actionbar = new Gtk.ActionBar () { + css_classes = { Granite.STYLE_CLASS_FLAT } + }; actionbar.pack_start (add_tasklist_button); - actionbar.add_css_class (Granite.STYLE_CLASS_FLAT); - var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - sidebar.add_css_class (Granite.STYLE_CLASS_SIDEBAR); + var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { + css_classes = { Granite.STYLE_CLASS_SIDEBAR } + }; sidebar.append (sidebar_header); sidebar.append (scrolledwindow); sidebar.append (actionbar); var main_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), - show_title_buttons = false + show_title_buttons = false, + css_classes = { Granite.STYLE_CLASS_DEFAULT_DECORATION, Granite.STYLE_CLASS_FLAT } }; main_header.pack_end (new Gtk.WindowControls (Gtk.PackType.END)); - main_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); - main_header.add_css_class (Granite.STYLE_CLASS_FLAT); task_list_grid_stack = new Gtk.Stack (); - var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - main_box.add_css_class (Granite.STYLE_CLASS_BACKGROUND); + var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { + css_classes = { Granite.STYLE_CLASS_BACKGROUND } + }; main_box.append (main_header); main_box.append (task_list_grid_stack); diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index c8e8d91841..440f134745 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -42,36 +42,32 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { editable_title = new EditableLabel () { margin_start = 24, - hexpand = true + hexpand = true, + css_classes = { Granite.STYLE_CLASS_H1_LABEL, Granite.STYLE_CLASS_ACCENT } }; - editable_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); - editable_title.add_css_class (Granite.STYLE_CLASS_ACCENT); var list_settings_popover = new Tasks.Widgets.ListSettingsPopover (); var settings_button = new Gtk.MenuButton () { + popover = list_settings_popover, margin_end = 24, valign = Gtk.Align.CENTER, hexpand = false, + icon_name = "view-more-symbolic", tooltip_text = _("Edit Name and Appearance"), - popover = list_settings_popover, - icon_name = "view-more-symbolic" + css_classes = { Granite.STYLE_CLASS_FLAT, Granite.STYLE_CLASS_DIM_LABEL } }; - settings_button.add_css_class (Granite.STYLE_CLASS_FLAT); - settings_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); - var placeholder = new Gtk.Label (_("No Tasks")); - placeholder.show (); - - placeholder.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); - placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); + var placeholder = new Gtk.Label (_("No Tasks")) { + css_classes = { Granite.STYLE_CLASS_DIM_LABEL, Granite.STYLE_CLASS_H2_LABEL} + }; add_task_list = new Gtk.ListBox () { margin_top = 24, selection_mode = Gtk.SelectionMode.SINGLE, - activate_on_single_click = true + activate_on_single_click = true, + css_classes = { Granite.STYLE_CLASS_BACKGROUND } }; - add_task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); var add_task_row = new Tasks.Widgets.TaskRow.for_source (source); add_task_row.unselect.connect (on_row_unselect); @@ -99,9 +95,9 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { task_list = new Gtk.ListBox () { selection_mode = Gtk.SelectionMode.SINGLE, - activate_on_single_click = true + activate_on_single_click = true, + css_classes = { Granite.STYLE_CLASS_BACKGROUND } }; - task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); task_list.set_placeholder (placeholder); task_list.set_sort_func (sort_function); diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 4104aa65ed..c9934b8bd1 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -167,32 +167,32 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { child = location_popover }; - // location_popover.value_format.connect ((value) => { - // if (value == null) { - // return null; - // } - // var location = (value.display_name == null ? value.postal_address : value.display_name); - - // switch (value.proximity) { - // case Tasks.LocationProximity.ARRIVE: - // return _("Arriving: %s").printf (location); - - // case Tasks.LocationProximity.DEPART: - // return _("Leaving: %s").printf (location); - - // default: - // return location; - // } - // }); - - // location_popover.value_changed.connect ((value) => { - // if (!task_form_revealer.reveal_child) { - // if (value == null) { - // location_popover_revealer.reveal_child = false; - // } - // save_task (task); - // } - // }); + location_popover.value_format.connect ((value) => { + if (value == null) { + return null; + } + var location = (value.display_name == null ? value.postal_address : value.display_name); + + switch (value.proximity) { + case Tasks.LocationProximity.ARRIVE: + return _("Arriving: %s").printf (location); + + case Tasks.LocationProximity.DEPART: + return _("Leaving: %s").printf (location); + + default: + return location; + } + }); + + location_popover.value_changed.connect ((value) => { + if (!task_form_revealer.reveal_child) { + if (value == null) { + location_popover_revealer.reveal_child = false; + } + save_task (task); + } + }); description_label = new Gtk.Label (null) { xalign = 0, @@ -445,7 +445,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { task_detail_revealer.remove_css_class (Granite.STYLE_CLASS_DIM_LABEL); due_datetime_popover_revealer.reveal_child = false; - // location_popover_revealer.reveal_child = false; + location_popover_revealer.reveal_child = false; description_label_revealer.reveal_child = false; description_textbuffer.text = ""; @@ -482,13 +482,13 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { due_datetime_popover_revealer.reveal_child = true; } - // var location = Util.get_ecalcomponent_location (task); - // if (location == null) { - // location_popover_revealer.reveal_child = false; - // } else { - // location_popover.value = location; - // location_popover_revealer.reveal_child = true; - // } + var location = Util.get_ecalcomponent_location (task); + if (location == null) { + location_popover_revealer.reveal_child = false; + } else { + location_popover.value = location; + location_popover_revealer.reveal_child = true; + } if (ical_task.get_description () == null) { description_label.label = ""; @@ -513,11 +513,11 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private void task_details_reveal_request (bool value) { description_label_revealer.reveal_child = value && description_label.label != null && description_label.label.strip ().length > 0; due_datetime_popover_revealer.reveal_child = !value || due_datetime_popover.value != null; - // location_popover_revealer.reveal_child = !value || location_popover.value != null; + location_popover_revealer.reveal_child = !value || location_popover.value != null; task_detail_revealer.reveal_child = description_label_revealer.reveal_child || - due_datetime_popover_revealer.reveal_child; - // location_popover_revealer.reveal_child; + due_datetime_popover_revealer.reveal_child || + location_popover_revealer.reveal_child; } private void remove_request () { From 495dd9b8124f37c5ecf070ed4390358ff01a3ffd Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 15:57:03 +0900 Subject: [PATCH 19/86] Use ActionBar for task buttons --- src/Widgets/EntryPopover/Location.vala | 4 ++-- src/Widgets/TaskRow.vala | 27 +++++++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Widgets/EntryPopover/Location.vala b/src/Widgets/EntryPopover/Location.vala index 837cb37819..5205bcfb46 100644 --- a/src/Widgets/EntryPopover/Location.vala +++ b/src/Widgets/EntryPopover/Location.vala @@ -1,5 +1,5 @@ /* -* Copyright 2021 elementary, Inc. (https://elementary.io) +* Copyright 2021-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -20,7 +20,7 @@ public class Tasks.Widgets.EntryPopover.Location : Generic { // private GtkChamplain.Embed map_embed; private Gtk.SearchEntry search_entry; - private GLib.Cancellable search_cancellable; + // private GLib.Cancellable search_cancellable; // private Granite.Widgets.ModeButton location_mode; // private Marker point; diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index c9934b8bd1..c7a3458e5e 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -235,16 +235,19 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var cancel_button = new Gtk.Button.with_label (_("Cancel")); - var save_button = new Gtk.Button.with_label (created ? _("Save Changes") : _("Add Task")); - save_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); + var save_button = new Gtk.Button.with_label (created ? _("Save Changes") : _("Add Task")) { + css_classes = { Granite.STYLE_CLASS_SUGGESTED_ACTION } + }; + + var right_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); + right_buttons_box.append (cancel_button); + right_buttons_box.append (save_button); - var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { - baseline_position = Gtk.BaselinePosition.CENTER, - margin_top = 12 + var button_box = new Gtk.ActionBar () { + margin_top = 12, + css_classes = { Granite.STYLE_CLASS_BACKGROUND } }; - // button_box.set_layout (Gtk.ButtonBoxStyle.END); - button_box.append (cancel_button); - button_box.append (save_button); + button_box.pack_end (right_buttons_box); var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) { margin_top = 6, @@ -298,10 +301,12 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { check.show (); state_stack.visible_child = check; - var delete_button = new Gtk.Button.with_label (_("Delete Task")); - delete_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); + var delete_button = new Gtk.Button.with_label (_("Delete Task")) { + halign = Gtk.Align.START, + css_classes = { Granite.STYLE_CLASS_DESTRUCTIVE_ACTION } + }; - button_box.append (delete_button); + button_box.pack_start (delete_button); delete_button.clicked.connect (() => { end_editing (); From 00cde6f9fd0d4d65c245d102a2c4c6a2fa3476b7 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 16:29:24 +0900 Subject: [PATCH 20/86] Fix delete_list style --- src/Widgets/ListSettingsPopover.vala | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index a77a48f1d7..7b5503e83a 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -34,6 +34,8 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { private Gtk.CheckButton color_button_none; construct { + autohide = true; + color_button_blue = new Gtk.CheckButton (); color_button_blue.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); @@ -132,11 +134,19 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { MainWindow.ACTION_PREFIX + MainWindow.ACTION_DELETE_SELECTED_LIST ); - var delete_list_menuitem = new Gtk.Button () { - action_name = delete_list_accel_label.action_name, - child = delete_list_accel_label + var delete_list_menuitem = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { + css_classes = { Granite.STYLE_CLASS_MENUITEM, Granite.STYLE_CLASS_DESTRUCTIVE_ACTION } }; - delete_list_menuitem.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); + delete_list_menuitem.append (delete_list_accel_label); + + var gesture_click = new Gtk.GestureClick (); + delete_list_menuitem.add_controller (gesture_click); + gesture_click.released.connect (() => { + hide (); + + unowned var main_window = (Gtk.ApplicationWindow) get_root (); + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).activate (null); + }); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top = 3, From c01332ce473e0c92478e65c58848cd40ae16e91c Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 20:38:30 +0900 Subject: [PATCH 21/86] Try to fix EditableLabel --- data/EditableLabel.css | 2 +- src/Application.vala | 7 +++---- src/MainWindow.vala | 15 +++++++-------- src/Widgets/EditableLabel.vala | 31 +++++++++++++++++-------------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/data/EditableLabel.css b/data/EditableLabel.css index 94c2c429b3..673483c2eb 100644 --- a/data/EditableLabel.css +++ b/data/EditableLabel.css @@ -18,7 +18,7 @@ * */ -.editable-label entry { +editable-label entry { background: transparent; border: none; box-shadow: none; diff --git a/src/Application.vala b/src/Application.vala index 27710a271d..ba61770703 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -75,10 +75,9 @@ public class Tasks.Application : Gtk.Application { model.start.begin (); var main_window = new MainWindow (this); - add_window (main_window); - var granite_settings = Granite.Settings.get_default (); - var gtk_settings = Gtk.Settings.get_default (); + unowned var granite_settings = Granite.Settings.get_default (); + unowned var gtk_settings = Gtk.Settings.get_default (); gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; @@ -95,7 +94,7 @@ public class Tasks.Application : Gtk.Application { if (providers == null) { providers = new Gee.HashMap (); } - var task_list = (E.SourceTaskList?) source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); + unowned var task_list = (E.SourceTaskList?) source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); // Ensure we get a valid CSS color, not including FF var color = task_list.dup_color ().slice (0, 7); if (!providers.has_key (color)) { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 0f296ce3c5..8740069efa 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -55,7 +55,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { construct { add_action_entries (ACTION_ENTRIES, this); - var application_instance = (Gtk.Application) GLib.Application.get_default (); + unowned var application_instance = (Gtk.Application) GLib.Application.get_default (); foreach (var action in action_accelerators.get_keys ()) { application_instance.set_accels_for_action ( ACTION_PREFIX + action, action_accelerators[action].to_array () @@ -70,11 +70,10 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var sidebar_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), - show_title_buttons = false + show_title_buttons = false, + css_classes = { Granite.STYLE_CLASS_DEFAULT_DECORATION, Granite.STYLE_CLASS_FLAT } }; sidebar_header.pack_start (new Gtk.WindowControls (Gtk.PackType.START)); - sidebar_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); - sidebar_header.add_css_class (Granite.STYLE_CLASS_FLAT); var scrolledwindow = new Gtk.ScrolledWindow () { hexpand = true, @@ -202,7 +201,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var task_lists = registry.list_sources (E.SOURCE_EXTENSION_TASK_LIST); task_lists.foreach ((source) => { - E.SourceTaskList list = (E.SourceTaskList)source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); + unowned var list = (E.SourceTaskList)source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); if (list.selected == true && source.enabled == true && !source.has_extension (E.SOURCE_EXTENSION_COLLECTION)) { add_source (source); @@ -279,7 +278,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { try { var new_source = new E.Source (null, null); - var new_source_tasklist_extension = (E.SourceTaskList) new_source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); + unowned var new_source_tasklist_extension = (E.SourceTaskList) new_source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); new_source.display_name = _("New list"); new_source_tasklist_extension.color = "#0e9a83"; @@ -321,7 +320,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } private void action_delete_selected_list () { - var list_row = ((Tasks.Widgets.SourceRow) listbox.get_selected_row ()); + unowned var list_row = ((Tasks.Widgets.SourceRow) listbox.get_selected_row ()); var source = list_row.source; if (Tasks.Application.model.is_remove_task_list_supported (source)) { @@ -454,7 +453,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } else { source_rows[source].update_request (); - var task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_visible_child (); + unowned var task_list_grid = (Tasks.Widgets.TaskListGrid) task_list_grid_stack.get_visible_child (); if (task_list_grid != null) { task_list_grid.update_request (); } diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index 4c7567da87..9976b1571f 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -51,22 +51,18 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { static construct { set_layout_manager_type (typeof (Gtk.BinLayout)); + label_provider = new Gtk.CssProvider (); label_provider.load_from_resource ("io/elementary/tasks/EditableLabel.css"); + + set_css_name ("editable-label"); } construct { - add_css_class ("editable-label"); get_style_context ().add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); valign = Gtk.Align.CENTER; - var motion_controller = new Gtk.EventControllerMotion (); - add_controller (motion_controller); - - var press_controller = new Gtk.GestureClick (); - add_controller (press_controller); - title = new Gtk.Label ("") { ellipsize = Pango.EllipsizeMode.END, xalign = 0 @@ -74,9 +70,9 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { var edit_button = new Gtk.Button () { icon_name = "edit-symbolic", - tooltip_text = _("Edit…") + tooltip_text = _("Edit…"), + css_classes = { Granite.STYLE_CLASS_FLAT } }; - edit_button.add_css_class (Granite.STYLE_CLASS_FLAT); var button_revealer = new Gtk.Revealer () { valign = Gtk.Align.CENTER, @@ -91,24 +87,27 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { box.append (button_revealer); entry = new Gtk.Entry () { - hexpand = true + hexpand = true, }; + entry.add_css_class ("editable-entry"); entry.get_style_context ().add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - var focus_controller = new Gtk.EventControllerFocus (); - entry.add_controller (focus_controller); - stack = new Gtk.Stack () { hhomogeneous = false, transition_type = Gtk.StackTransitionType.CROSSFADE }; stack.add_child (box); stack.add_child (entry); - stack.set_parent (this); // ? bind_property ("text", title, "label"); + var motion_controller = new Gtk.EventControllerMotion (); + add_controller (motion_controller); + + var press_controller = new Gtk.GestureClick (); + add_controller (press_controller); + motion_controller.enter.connect ((x, y) => { button_revealer.reveal_child = true; }); @@ -127,6 +126,10 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { } }); + + var focus_controller = new Gtk.EventControllerFocus (); + entry.add_controller (focus_controller); + focus_controller.leave.connect (() => { if (stack.visible_child == entry) { editing = false; From d4f6b2fd4dfd4f72b0e04e4185e983895449a6fb Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 20:58:24 +0900 Subject: [PATCH 22/86] Fix EntryPopover style --- data/EntryPopover.css | 15 +++++++++++---- src/Widgets/EntryPopover/Generic.vala | 14 +++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/data/EntryPopover.css b/data/EntryPopover.css index 4436eeaa74..cd6124448a 100644 --- a/data/EntryPopover.css +++ b/data/EntryPopover.css @@ -18,21 +18,28 @@ * */ -entry-popover grid { +entry-popover .container { border-radius: 3px; background: @SILVER_300; } -entry-popover button { +entry-popover menubutton { + background: transparent; color: @SILVER_900; font-size: 0.9em; font-weight: 600; } -entry-popover.error grid { +entry-popover menubutton * { + background: transparent; + border: none; + box-shadow: none; +} + +entry-popover.error .container { background: alpha(@error_color, 0.2); } -entry-popover.error button { +entry-popover.error .delete-button { color: @error_color; } diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index cf9e1c5a04..b1c6eece5c 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -40,16 +40,17 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { class construct { set_css_name ("entry-popover"); + set_layout_manager_type (typeof (Gtk.BinLayout)); } static construct { - set_layout_manager_type (typeof (Gtk.BinLayout)); - style_provider = new Gtk.CssProvider (); style_provider.load_from_resource ("io/elementary/tasks/EntryPopover.css"); } construct { + get_style_context ().add_provider_for_display (Gdk.Display.get_default (), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + popover = new Gtk.Popover () { child = popover_button, autohide = true @@ -68,13 +69,11 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { child = popover_button_box, css_classes = { Granite.STYLE_CLASS_FLAT } }; - popover_button.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic") { tooltip_text = _("Remove"), - css_classes = { Granite.STYLE_CLASS_FLAT } + css_classes = { Granite.STYLE_CLASS_FLAT, "delete-button" } }; - delete_button.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var delete_button_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT, @@ -82,8 +81,9 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { child = delete_button }; - var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - button_box.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { + css_classes = { "container" } + }; button_box.append (popover_button); button_box.append (delete_button_revealer); button_box.set_parent (this); From cbd62327d9b0855e3973a6b8ed6b1b6d6f37a8b6 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 21:07:08 +0900 Subject: [PATCH 23/86] Finally fix EntryPopover styles --- data/EntryPopover.css | 2 +- src/Widgets/EntryPopover/DateTime.vala | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/data/EntryPopover.css b/data/EntryPopover.css index cd6124448a..fc41dc517d 100644 --- a/data/EntryPopover.css +++ b/data/EntryPopover.css @@ -30,7 +30,7 @@ entry-popover menubutton { font-weight: 600; } -entry-popover menubutton * { +entry-popover menubutton button.toggle { background: transparent; border: none; box-shadow: none; diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index 4733d3bb36..5485d981ec 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -54,23 +54,27 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { margin_top = 3 }; - var today_button = new Gtk.Button.with_label (_("Today")) { - css_classes = { Granite.STYLE_CLASS_FLAT } - }; + var today_box_gesture_click = new Gtk.GestureClick (); + var today_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { + css_classes = { Granite.STYLE_CLASS_MENUITEM } + }; + today_box.append (new Gtk.Label (_("Today")) { hexpand = true, justify = Gtk.Justification.CENTER }); + today_box.add_controller (today_box_gesture_click); + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top = 3 }; - box.append (today_button); + box.append (today_box); box.append (today_separator); box.append (calendar); box.append (timepicker_revealer); - + popover.child = box; - + popover.show.connect (on_popover_show); - - today_button.clicked.connect (on_today_button_clicked); + + today_box_gesture_click.released.connect (on_today_button_clicked); calendar.day_selected.connect (on_calendar_day_selected); timepicker.time_changed.connect (on_timepicker_time_changed); } From 8adae242cc6c9d4a108d1570efcc5e358c451954 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 21:10:22 +0900 Subject: [PATCH 24/86] Fix lint --- src/MainWindow.vala | 5 ++--- src/Widgets/EntryPopover/DateTime.vala | 8 ++++---- src/Widgets/EntryPopover/Generic.vala | 10 ++++------ src/Widgets/EntryPopover/Location.vala | 2 +- src/Widgets/ListSettingsPopover.vala | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8740069efa..d2cfc79254 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -182,14 +182,13 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { listbox.row_selected.connect (on_listbox_row_selected); - add_collection_source (registry.ref_builtin_task_list ()); - + var task_list_collections = registry.list_sources (E.SOURCE_EXTENSION_COLLECTION); task_list_collections.foreach ((collection_source) => { add_collection_source (collection_source); }); - + var last_selected_list = Application.settings.get_string ("selected-list"); if (last_selected_list == SCHEDULED_LIST_UID) { diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index 5485d981ec..0c75ecad03 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -61,7 +61,7 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { }; today_box.append (new Gtk.Label (_("Today")) { hexpand = true, justify = Gtk.Justification.CENTER }); today_box.add_controller (today_box_gesture_click); - + var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top = 3 }; @@ -69,11 +69,11 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { box.append (today_separator); box.append (calendar); box.append (timepicker_revealer); - + popover.child = box; - + popover.show.connect (on_popover_show); - + today_box_gesture_click.released.connect (on_today_button_clicked); calendar.day_selected.connect (on_calendar_day_selected); timepicker.time_changed.connect (on_timepicker_time_changed); diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index b1c6eece5c..891362a3df 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -27,7 +27,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { public T value { get; set; } private Gtk.MenuButton popover_button; - private static Gtk.CssProvider style_provider; private Gtk.Label label; private T value_on_popover_show; @@ -44,13 +43,12 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { } static construct { - style_provider = new Gtk.CssProvider (); + var style_provider = new Gtk.CssProvider (); style_provider.load_from_resource ("io/elementary/tasks/EntryPopover.css"); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } - construct { - get_style_context ().add_provider_for_display (Gdk.Display.get_default (), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - + construct { popover = new Gtk.Popover () { child = popover_button, autohide = true @@ -63,7 +61,7 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { popover_button_box.append (new Gtk.Image.from_icon_name (icon_name)); } popover_button_box.append (label); - + popover_button = new Gtk.MenuButton () { popover = popover, child = popover_button_box, diff --git a/src/Widgets/EntryPopover/Location.vala b/src/Widgets/EntryPopover/Location.vala index 5205bcfb46..a3d5ba8c19 100644 --- a/src/Widgets/EntryPopover/Location.vala +++ b/src/Widgets/EntryPopover/Location.vala @@ -65,7 +65,7 @@ public class Tasks.Widgets.EntryPopover.Location : Generic { margin_top = 12, margin_bottom = 12, margin_start = 12, - margin_end = 12 + margin_end = 12 }; box.append (search_entry); diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index 7b5503e83a..cd13454741 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -138,7 +138,7 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { css_classes = { Granite.STYLE_CLASS_MENUITEM, Granite.STYLE_CLASS_DESTRUCTIVE_ACTION } }; delete_list_menuitem.append (delete_list_accel_label); - + var gesture_click = new Gtk.GestureClick (); delete_list_menuitem.add_controller (gesture_click); gesture_click.released.connect (() => { From ab073f920f4755bc95241f9688ae020788f8dd0e Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 21:16:27 +0900 Subject: [PATCH 25/86] Finally fix EditableLabel style --- data/EditableLabel.css | 4 ++++ src/Widgets/EditableLabel.vala | 18 +++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/data/EditableLabel.css b/data/EditableLabel.css index 673483c2eb..642248eb1c 100644 --- a/data/EditableLabel.css +++ b/data/EditableLabel.css @@ -25,3 +25,7 @@ editable-label entry { color: inherit; padding: 0; } + +editable-label entry text { + padding: 0; +} \ No newline at end of file diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index 9976b1571f..6905fb4efc 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -22,8 +22,6 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { public signal void changed (); - private static Gtk.CssProvider label_provider; - private Gtk.Label title; private Gtk.Entry entry; private Gtk.Stack stack; @@ -49,18 +47,18 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { } } - static construct { + class construct { set_layout_manager_type (typeof (Gtk.BinLayout)); - - label_provider = new Gtk.CssProvider (); - label_provider.load_from_resource ("io/elementary/tasks/EditableLabel.css"); - set_css_name ("editable-label"); } - construct { - get_style_context ().add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + static construct { + var style_provider = new Gtk.CssProvider (); + style_provider.load_from_resource ("io/elementary/tasks/EditableLabel.css"); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + } + construct { valign = Gtk.Align.CENTER; title = new Gtk.Label ("") { @@ -89,8 +87,6 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { entry = new Gtk.Entry () { hexpand = true, }; - entry.add_css_class ("editable-entry"); - entry.get_style_context ().add_provider (label_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); stack = new Gtk.Stack () { hhomogeneous = false, From 31501347042f88184560a5ea12e7fef10f64b259 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 21:21:57 +0900 Subject: [PATCH 26/86] Use the same mechanism for TaskRow --- data/EditableLabel.css | 2 +- data/TaskRow.css | 14 +++++++------- src/Widgets/TaskRow.vala | 13 +++++++------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/data/EditableLabel.css b/data/EditableLabel.css index 642248eb1c..85376df38d 100644 --- a/data/EditableLabel.css +++ b/data/EditableLabel.css @@ -28,4 +28,4 @@ editable-label entry { editable-label entry text { padding: 0; -} \ No newline at end of file +} diff --git a/data/TaskRow.css b/data/TaskRow.css index 2e4bc04e48..698bfc7d0e 100644 --- a/data/TaskRow.css +++ b/data/TaskRow.css @@ -18,37 +18,37 @@ * */ -row { +task-row { transition: all 250ms ease-in-out; } -row:focus:not(.card) { +task-row:focus:not(.card) { background-color: shade(@base_color, 0.8); } -row.card { +task-row.card { background-color: @base_color; margin-bottom: 12px; margin-top: 1px; padding-top: 6px; } -row entry.flat { +task-row entry.flat { background: transparent; border-style: solid; border-color: transparent; padding: 0; } -row entry.flat:focus { +task-row entry.flat:focus { opacity: 1; } -row:not(.card) entry.add-task { +task-row:not(.card) entry.add-task { border-color: alpha(@text_color, 0.25); } -row.drag-active { +task-row.drag-active { background-color: @bg_color; border: 1px solid @borders; border-radius: 3px; diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index c7a3458e5e..f6e66cb1cd 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -50,8 +50,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Gtk.Revealer task_form_revealer; private Gtk.TextBuffer description_textbuffer; - private static Gtk.CssProvider taskrow_provider; - private TaskRow (ECal.Component task, E.Source source) { Object (task: task, source: source); } @@ -67,9 +65,14 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { Object (source: source, task: task, is_scheduled_view: is_scheduled_view); } + class construct { + set_css_name ("task-row"); + } + static construct { - taskrow_provider = new Gtk.CssProvider (); - taskrow_provider.load_from_resource ("io/elementary/tasks/TaskRow.css"); + var style_provider = new Gtk.CssProvider (); + style_provider.load_from_resource ("io/elementary/tasks/TaskRow.css"); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } construct { @@ -100,7 +103,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { summary_entry = new Gtk.Entry (); summary_entry.add_css_class (Granite.STYLE_CLASS_FLAT); - summary_entry.get_style_context ().add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); due_datetime_popover = new Tasks.Widgets.EntryPopover.DateTime (); @@ -295,7 +297,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { margin_end = 12; add_css_class (Granite.STYLE_CLASS_ROUNDED); - get_style_context ().add_provider (taskrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); if (created) { check.show (); From 358dced07172ab62660979002a7ee99a4a63b2c4 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 21:52:25 +0900 Subject: [PATCH 27/86] Fix tasklist colors --- src/TaskModel.vala | 8 ++-- src/Widgets/ListSettingsPopover.vala | 69 +++++++++++----------------- src/Widgets/TaskListGrid.vala | 2 +- 3 files changed, 33 insertions(+), 46 deletions(-) diff --git a/src/TaskModel.vala b/src/TaskModel.vala index 0cefb44381..2859a185f8 100644 --- a/src/TaskModel.vala +++ b/src/TaskModel.vala @@ -596,7 +596,7 @@ public class Tasks.TaskModel : Object { debug ("WebDAV Rename '%s'", task_list.get_uid ()); var collection_source_webdav_session = new E.WebDAVSession (collection_source); - var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND); + unowned var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND); var credentials_provider = new E.SourceCredentialsProvider (registry); E.NamedParameters credentials; @@ -630,7 +630,7 @@ public class Tasks.TaskModel : Object { } else if ("gtasks" == ((E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST)).backend_name && E.OAuth2Services.is_supported ()) { debug ("GTasks Rename '%s'", task_list.get_uid ()); - var task_list_id = ((E.SourceResource) task_list.get_extension ( + unowned var task_list_id = ((E.SourceResource) task_list.get_extension ( E.SOURCE_EXTENSION_RESOURCE )).identity.replace ("gtasks::", ""); #if !HAS_EDS_3_46 @@ -680,7 +680,7 @@ public class Tasks.TaskModel : Object { if (!task_list.has_extension (E.SOURCE_EXTENSION_TASK_LIST)) { throw new Tasks.TaskModelError.INVALID_ARGUMENT ("Changing the color is not supported by this source."); } - var task_list_extension = (E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST); + unowned var task_list_extension = (E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST); var previous_color = task_list_extension.dup_color (); var registry = get_registry_sync (); @@ -704,7 +704,7 @@ public class Tasks.TaskModel : Object { debug ("Update %s color for '%s'", backend_name, task_list.get_uid ()); var collection_source_webdav_session = new E.WebDAVSession (collection_source); - var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND); + unowned var source_webdav_extension = (E.SourceWebdav) task_list.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND); var credentials_provider = new E.SourceCredentialsProvider (registry); E.NamedParameters credentials; diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index cd13454741..9153e9ff9c 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -19,7 +19,7 @@ */ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { - public E.Source source { get; set; } + public E.Source source { get; construct set; } private Gtk.CheckButton color_button_red; private Gtk.CheckButton color_button_orange; @@ -33,77 +33,64 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { private Gtk.CheckButton color_button_slate; private Gtk.CheckButton color_button_none; + public ListSettingsPopover (E.Source source) { + Object (source: source); + } + construct { autohide = true; - color_button_blue = new Gtk.CheckButton (); - - color_button_blue.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_blue.add_css_class ("blue"); + color_button_blue = new Gtk.CheckButton () { + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "blue" } + }; color_button_mint = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "mint" } }; - color_button_mint.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_mint.add_css_class ("mint"); - color_button_green = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "green" } }; - color_button_green.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_green.add_css_class ("green"); color_button_yellow = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "yellow" } }; - color_button_yellow.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_yellow.add_css_class ("yellow"); - color_button_orange = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "orange" } }; - color_button_orange.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_orange.add_css_class ("orange"); - color_button_red = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "red" } }; - color_button_red.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_red.add_css_class ("red"); - color_button_pink = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "pink" } }; - color_button_pink.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_pink.add_css_class ("pink"); - color_button_purple = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "purple" } }; - color_button_purple.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_purple.add_css_class ("purple"); - color_button_brown = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "brown" } }; - color_button_brown.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_brown.add_css_class ("brown"); - color_button_slate = new Gtk.CheckButton () { - group = color_button_blue + group = color_button_blue, + css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "slate" } }; - color_button_slate.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); - color_button_slate.add_css_class ("slate"); - + // FIXME: this CheckButton is unused color_button_none = new Gtk.CheckButton () { group = color_button_blue }; @@ -268,7 +255,7 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { private string get_task_list_color (E.Source source) { if (source.has_extension (E.SOURCE_EXTENSION_TASK_LIST)) { - var task_list = (E.SourceTaskList) source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); + unowned var task_list = (E.SourceTaskList) source.get_extension (E.SOURCE_EXTENSION_TASK_LIST); return task_list.dup_color (); } return ""; diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 440f134745..f381b05e82 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -46,7 +46,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { css_classes = { Granite.STYLE_CLASS_H1_LABEL, Granite.STYLE_CLASS_ACCENT } }; - var list_settings_popover = new Tasks.Widgets.ListSettingsPopover (); + var list_settings_popover = new Tasks.Widgets.ListSettingsPopover (source); var settings_button = new Gtk.MenuButton () { popover = list_settings_popover, From d893599bc42ebda11e24d8ba0ed7dac2cca581f1 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 21:52:53 +0900 Subject: [PATCH 28/86] Fix --- src/TaskModel.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TaskModel.vala b/src/TaskModel.vala index 2859a185f8..388b94eda5 100644 --- a/src/TaskModel.vala +++ b/src/TaskModel.vala @@ -630,7 +630,7 @@ public class Tasks.TaskModel : Object { } else if ("gtasks" == ((E.SourceTaskList) task_list.get_extension (E.SOURCE_EXTENSION_TASK_LIST)).backend_name && E.OAuth2Services.is_supported ()) { debug ("GTasks Rename '%s'", task_list.get_uid ()); - unowned var task_list_id = ((E.SourceResource) task_list.get_extension ( + var task_list_id = ((E.SourceResource) task_list.get_extension ( E.SOURCE_EXTENSION_RESOURCE )).identity.replace ("gtasks::", ""); #if !HAS_EDS_3_46 From acc29300757a6fad16f9845cd2c37dba42758e23 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 22:00:58 +0900 Subject: [PATCH 29/86] Use Gtk.Grid for task buttons --- src/Widgets/TaskRow.vala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index f6e66cb1cd..49c7757361 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -241,22 +241,24 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { css_classes = { Granite.STYLE_CLASS_SUGGESTED_ACTION } }; - var right_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); + var right_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { + halign = Gtk.Align.END + }; right_buttons_box.append (cancel_button); right_buttons_box.append (save_button); - var button_box = new Gtk.ActionBar () { + var button_grid = new Gtk.Grid () { margin_top = 12, - css_classes = { Granite.STYLE_CLASS_BACKGROUND } + column_homogeneous = true }; - button_box.pack_end (right_buttons_box); + button_grid.attach (right_buttons_box, 1, 0); var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) { margin_top = 6, margin_bottom = 6 }; form_box.append (description_frame); - form_box.append (button_box); + form_box.append (button_grid); task_form_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN, @@ -307,7 +309,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { css_classes = { Granite.STYLE_CLASS_DESTRUCTIVE_ACTION } }; - button_box.pack_start (delete_button); + button_grid.attach (delete_button, 0, 0); delete_button.clicked.connect (() => { end_editing (); From a3c1e2e6b5319b3926a48d9d2827628aef2ad30c Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 22:20:01 +0900 Subject: [PATCH 30/86] DRY --- meson.build | 9 ++++--- src/Widgets/EntryPopover/DateTime.vala | 9 ++----- src/Widgets/ListSettingsPopover.vala | 9 +++---- src/Widgets/PopoverButton.vala | 34 ++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 src/Widgets/PopoverButton.vala diff --git a/meson.build b/meson.build index c5fa360f26..5b0d8dffbd 100644 --- a/meson.build +++ b/meson.build @@ -60,19 +60,20 @@ executable( 'src/Application.vala', 'src/Location.vala', 'src/MainWindow.vala', + 'src/TaskModel.vala', 'src/TodayTaskMonitor.vala', 'src/Util.vala', - 'src/Widgets/EditableLabel.vala', 'src/Widgets/EntryPopover/DateTime.vala', 'src/Widgets/EntryPopover/Generic.vala', 'src/Widgets/EntryPopover/Location.vala', + 'src/Widgets/EditableLabel.vala', + 'src/Widgets/ListSettingsPopover.vala', + 'src/Widgets/PopoverButton.vala', 'src/Widgets/ScheduledRow.vala', - 'src/Widgets/SourceRow.vala', 'src/Widgets/ScheduledTaskListGrid.vala', + 'src/Widgets/SourceRow.vala', 'src/Widgets/TaskListGrid.vala', 'src/Widgets/TaskRow.vala', - 'src/Widgets/ListSettingsPopover.vala', - 'src/TaskModel.vala', dependencies: tasks_deps, install : true ) diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index 0c75ecad03..39e451ea83 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -54,13 +54,8 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { margin_top = 3 }; - var today_box_gesture_click = new Gtk.GestureClick (); - - var today_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { - css_classes = { Granite.STYLE_CLASS_MENUITEM } - }; + var today_box = new Widgets.PopoverButton (); today_box.append (new Gtk.Label (_("Today")) { hexpand = true, justify = Gtk.Justification.CENTER }); - today_box.add_controller (today_box_gesture_click); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top = 3 @@ -74,7 +69,7 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { popover.show.connect (on_popover_show); - today_box_gesture_click.released.connect (on_today_button_clicked); + today_box.clicked.connect (on_today_button_clicked); calendar.day_selected.connect (on_calendar_day_selected); timepicker.time_changed.connect (on_timepicker_time_changed); } diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index 9153e9ff9c..d7439dc205 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -121,14 +121,11 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { MainWindow.ACTION_PREFIX + MainWindow.ACTION_DELETE_SELECTED_LIST ); - var delete_list_menuitem = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { - css_classes = { Granite.STYLE_CLASS_MENUITEM, Granite.STYLE_CLASS_DESTRUCTIVE_ACTION } - }; + var delete_list_menuitem = new Widgets.PopoverButton (); + delete_list_menuitem.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); delete_list_menuitem.append (delete_list_accel_label); - var gesture_click = new Gtk.GestureClick (); - delete_list_menuitem.add_controller (gesture_click); - gesture_click.released.connect (() => { + delete_list_menuitem.clicked.connect (() => { hide (); unowned var main_window = (Gtk.ApplicationWindow) get_root (); diff --git a/src/Widgets/PopoverButton.vala b/src/Widgets/PopoverButton.vala new file mode 100644 index 0000000000..6f2fcae581 --- /dev/null +++ b/src/Widgets/PopoverButton.vala @@ -0,0 +1,34 @@ +/* +* Copyright 2023 elementary, Inc. (https://elementary.io) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 3 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* 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 along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +class Tasks.Widgets.PopoverButton : Gtk.Box { + public signal void clicked (); + + construct { + orientation = Gtk.Orientation.HORIZONTAL; + spacing = 0; + css_classes = { Granite.STYLE_CLASS_MENUITEM }; + + var gesture_click = new Gtk.GestureClick (); + add_controller (gesture_click); + + gesture_click.released.connect (() => clicked ()); + } +} \ No newline at end of file From 061695fd1712b3d442032a5e2948769a67164351 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 22:25:25 +0900 Subject: [PATCH 31/86] Use PopoverButton --- src/MainWindow.vala | 16 ++++++++++------ src/Widgets/ListSettingsPopover.vala | 2 +- src/Widgets/PopoverButton.vala | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index d2cfc79254..cfc7714c1d 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -37,6 +37,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { private Gee.Collection? collection_sources; private Gtk.Stack task_list_grid_stack; private Gtk.Box add_tasklist_buttonbox; + private Gtk.Popover add_tasklist_popover; public MainWindow (Gtk.Application application) { Object ( @@ -84,9 +85,8 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { add_tasklist_buttonbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); // TODO: check spacing - var online_accounts_button = new Gtk.Button () { - label = _("Online Accounts Settings…") - }; + var online_accounts_button = new Widgets.PopoverButton (); + online_accounts_button.append (new Gtk.Label (_("Online Accounts Settings…"))); var add_tasklist_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3) { margin_top = 3, @@ -96,7 +96,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { add_tasklist_box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); add_tasklist_box.append (online_accounts_button); - var add_tasklist_popover = new Gtk.Popover () { + add_tasklist_popover = new Gtk.Popover () { child = add_tasklist_box }; @@ -157,6 +157,8 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { settings.bind ("window-maximized", this, "maximized", SettingsBindFlags.DEFAULT); online_accounts_button.clicked.connect (() => { + add_tasklist_popover.popdown (); + try { AppInfo.launch_default_for_uri ("settings://accounts/online", null); } catch (Error e) { @@ -409,12 +411,14 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } collection_sources.add (collection_source); - var source_button = new Gtk.Button () { - label = Util.get_esource_collection_display_name (collection_source), + var source_button = new Widgets.PopoverButton () { sensitive = Application.model.is_add_task_list_supported (collection_source) }; + source_button.append (new Gtk.Label (Util.get_esource_collection_display_name (collection_source))); source_button.clicked.connect (() => { + add_tasklist_popover.popdown (); + add_new_list (collection_source); }); diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index d7439dc205..d6cb88a22d 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -126,7 +126,7 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { delete_list_menuitem.append (delete_list_accel_label); delete_list_menuitem.clicked.connect (() => { - hide (); + popdown (); unowned var main_window = (Gtk.ApplicationWindow) get_root (); ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).activate (null); diff --git a/src/Widgets/PopoverButton.vala b/src/Widgets/PopoverButton.vala index 6f2fcae581..28b485d2dd 100644 --- a/src/Widgets/PopoverButton.vala +++ b/src/Widgets/PopoverButton.vala @@ -31,4 +31,4 @@ class Tasks.Widgets.PopoverButton : Gtk.Box { gesture_click.released.connect (() => clicked ()); } -} \ No newline at end of file +} From b93f598fd3bbd19c97f82a24bd819c6d55349f58 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 22:30:29 +0900 Subject: [PATCH 32/86] MainWindow: Cleanup --- src/MainWindow.vala | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index cfc7714c1d..132a67282e 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -31,7 +31,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { private static Gee.MultiMap action_accelerators = new Gee.HashMultiMap (); - private uint configure_id; private Gtk.ListBox listbox; private Gee.HashMap? source_rows; private Gee.Collection? collection_sources; @@ -482,32 +481,4 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { return Source.REMOVE; }); } - - // public override bool configure_event (Gdk.EventConfigure event) { - // if (configure_id != 0) { - // GLib.Source.remove (configure_id); - // } - - // configure_id = Timeout.add (100, () => { - // configure_id = 0; - - // if (is_maximized) { - // Tasks.Application.settings.set_boolean ("window-maximized", true); - // } else { - // Tasks.Application.settings.set_boolean ("window-maximized", false); - - // Gdk.Rectangle rect; - // get_allocation (out rect); - // Tasks.Application.settings.set ("window-size", "(ii)", rect.width, rect.height); - - // int root_x, root_y; - // get_position (out root_x, out root_y); - // Tasks.Application.settings.set ("window-position", "(ii)", root_x, root_y); - // } - - // return false; - // }); - - // return base.configure_event (event); - // } } From 4675274f828a49d9fe375d1cc46001fae58f58cc Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 22:37:54 +0900 Subject: [PATCH 33/86] Rework loops --- src/Widgets/ScheduledTaskListGrid.vala | 7 ++++++- src/Widgets/TaskListGrid.vala | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index de0dfef425..a46896040a 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -48,15 +48,20 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { } private void remove_view (E.Source source) { + Gtk.Widget[] children_for_removal = {}; unowned var child = get_first_child (); while (child != null) { if (child is Tasks.Widgets.TaskRow && ((Tasks.Widgets.TaskRow) child).source == source) { - child.destroy (); + children_for_removal += child; } child = child.get_next_sibling (); } + for (int i = 0; i < children_for_removal.length; i++) { + children_for_removal[i].destroy (); + } + lock (views) { ECal.ClientView view; if (views.unset (source, out view)) { diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index f381b05e82..5b9fe17098 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -196,7 +196,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { while (child != null) { task_list.remove (child); - child = child.get_next_sibling (); + child = task_list.get_first_child (); } if (view != null) { From ace6d6a084ce2037b7dd80fdb5827bae9d7d50f1 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 22:59:43 +0900 Subject: [PATCH 34/86] Commit message --- src/MainWindow.vala | 2 +- src/Widgets/ListSettingsPopover.vala | 14 +++++++------- src/Widgets/SourceRow.vala | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 132a67282e..06491bc40e 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -334,7 +334,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { transient_for = this }; - unowned Gtk.Widget trash_button = message_dialog.add_button (_("Delete Anyway"), Gtk.ResponseType.YES); + unowned var trash_button = message_dialog.add_button (_("Delete Anyway"), Gtk.ResponseType.YES); trash_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); message_dialog.present (); diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index d6cb88a22d..7a9651fd22 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -125,13 +125,6 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { delete_list_menuitem.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); delete_list_menuitem.append (delete_list_accel_label); - delete_list_menuitem.clicked.connect (() => { - popdown (); - - unowned var main_window = (Gtk.ApplicationWindow) get_root (); - ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).activate (null); - }); - var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top = 3, margin_bottom = 3 @@ -203,6 +196,13 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { } }); + delete_list_menuitem.clicked.connect (() => { + popdown (); + + unowned var main_window = (Gtk.ApplicationWindow) get_root (); + ((SimpleAction) main_window.lookup_action (MainWindow.ACTION_DELETE_SELECTED_LIST)).activate (null); + }); + notify["source"].connect (() => { select_task_list_color (get_task_list_color (source)); }); diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index d16fa47190..8e90d21a9a 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -228,6 +228,8 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { public void remove_request () { revealer.reveal_child = false; GLib.Timeout.add (revealer.transition_duration, () => { + warning ("Here"); + // unparent (); destroy (); return GLib.Source.REMOVE; }); From e853c70cacfec200f114ace9493ee45251ca0c73 Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 23:52:43 +0900 Subject: [PATCH 35/86] Fix deletion of the task list --- src/Widgets/SourceRow.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 8e90d21a9a..89324b11a4 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -228,9 +228,9 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { public void remove_request () { revealer.reveal_child = false; GLib.Timeout.add (revealer.transition_duration, () => { - warning ("Here"); - // unparent (); + ((Gtk.ListBox) parent).remove (this); destroy (); + return GLib.Source.REMOVE; }); } From 263f12a6cd115fe5cafb1f2fff1759376a041b7b Mon Sep 17 00:00:00 2001 From: lenemter Date: Mon, 5 Jun 2023 23:58:12 +0900 Subject: [PATCH 36/86] Square delete button --- data/EntryPopover.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/EntryPopover.css b/data/EntryPopover.css index fc41dc517d..4253776c6c 100644 --- a/data/EntryPopover.css +++ b/data/EntryPopover.css @@ -36,6 +36,10 @@ entry-popover menubutton button.toggle { box-shadow: none; } +entry-popover .delete-button { + padding: 0.4em; +} + entry-popover.error .container { background: alpha(@error_color, 0.2); } From 640bcf1ab8a96c43df1b4075184cf2a0a1ffbbdb Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 00:00:35 +0900 Subject: [PATCH 37/86] editable-label button --- data/EditableLabel.css | 4 ++++ data/EntryPopover.css | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/data/EditableLabel.css b/data/EditableLabel.css index 85376df38d..e374f1848c 100644 --- a/data/EditableLabel.css +++ b/data/EditableLabel.css @@ -29,3 +29,7 @@ editable-label entry { editable-label entry text { padding: 0; } + +editable-label button { + padding: 0.4rem; +} diff --git a/data/EntryPopover.css b/data/EntryPopover.css index 4253776c6c..e19a86f5a4 100644 --- a/data/EntryPopover.css +++ b/data/EntryPopover.css @@ -37,7 +37,7 @@ entry-popover menubutton button.toggle { } entry-popover .delete-button { - padding: 0.4em; + padding: 0.4rem; } entry-popover.error .container { From 17498d386de470a81636ef61edaa940412fb7334 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 00:04:05 +0900 Subject: [PATCH 38/86] Some copyrights --- data/EditableLabel.css | 2 +- src/MainWindow.vala | 2 +- src/Widgets/ListSettingsPopover.vala | 2 +- src/Widgets/ScheduledTaskListGrid.vala | 2 +- src/Widgets/SourceRow.vala | 2 +- src/Widgets/TaskListGrid.vala | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/EditableLabel.css b/data/EditableLabel.css index e374f1848c..b009b0aba5 100644 --- a/data/EditableLabel.css +++ b/data/EditableLabel.css @@ -1,5 +1,5 @@ /* -* Copyright 2019 elementary, Inc. (https://elementary.io) +* Copyright 2019-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 06491bc40e..2716907e8f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1,5 +1,5 @@ /* -* Copyright 2019 elementary, Inc. (https://elementary.io) +* Copyright 2019-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index 7a9651fd22..995ba38b9c 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -1,5 +1,5 @@ /* -* Copyright 2019 elementary, Inc. (https://elementary.io) +* Copyright 2019-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index a46896040a..c5aeb8fcda 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -1,5 +1,5 @@ /* -* Copyright 2019 elementary, Inc. (https://elementary.io) +* Copyright 2019-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 89324b11a4..27076f6dca 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -1,5 +1,5 @@ /* -* Copyright 2019 elementary, Inc. (https://elementary.io) +* Copyright 2019-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 5b9fe17098..95bf690a9a 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -1,5 +1,5 @@ /* -* Copyright 2019 elementary, Inc. (https://elementary.io) +* Copyright 2019-2023 elementary, Inc. (https://elementary.io) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public From 5056f687fe9533d6258a80b7ee4565192e32cb98 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 00:35:13 +0900 Subject: [PATCH 39/86] Attempt to add dnd --- src/Widgets/SourceRow.vala | 212 ++++++++++++++++++------------------- src/Widgets/TaskRow.vala | 111 +++++++++---------- 2 files changed, 156 insertions(+), 167 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 27076f6dca..5e4fda74fa 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -82,117 +82,115 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { child = revealer; get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - // build_drag_and_drop (); + build_drag_and_drop (); update_request (); } - // private void build_drag_and_drop () { - // Gtk.drag_dest_set (this, Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.MOTION, Application.DRAG_AND_DROP_TASK_DATA, Gdk.DragAction.MOVE); - - // drag_motion.connect (on_drag_motion); - // drag_drop.connect (on_drag_drop); - // drag_data_received.connect (on_drag_data_received); - // drag_leave.connect (on_drag_leave); - // } - - // private bool on_drag_motion (Gdk.DragContext context, int x, int y, uint time) { - // var style_context = get_style_context (); - // if (!style_context.has_class ("drop-hover")) { - // style_context.add_class ("drop-hover"); - // } - // return true; - // } - - // private void on_drag_leave (Gdk.DragContext context, uint time_) { - // get_style_context ().remove_class ("drop-hover"); - // } - - // private Gee.HashMultiMap received_drag_data; - - // private async bool on_drag_drop_move_tasks () throws Error { - // E.SourceRegistry registry = yield Application.model.get_registry (); - // var move_successful = true; - - // var source_uids = received_drag_data.get_keys (); - // foreach (var source_uid in source_uids) { - // var src_source = registry.ref_source (source_uid); - - // var component_uids = received_drag_data.get (source_uid); - // foreach (var component_uid in component_uids) { - // if (!yield Application.model.move_task (src_source, source, component_uid)) { - // move_successful = false; - // } - // } - // } - // return move_successful; - // } - - // private bool on_drag_drop (Gdk.DragContext context, int x, int y, uint time) { - // var target = Gtk.drag_dest_find_target (this, context, null); - // if (target != Gdk.Atom.NONE) { - // Gtk.drag_get_data (this, context, target, time); - // } - - // var drop_successful = false; - // var move_successful = false; - // if (received_drag_data != null && received_drag_data.size > 0) { - // drop_successful = true; - - // on_drag_drop_move_tasks.begin ((obj, res) => { - // try { - // move_successful = on_drag_drop_move_tasks.end (res); - - // } catch (Error e) { - // var error_dialog = new Granite.MessageDialog ( - // _("Moving task failed"), - // _("There was an error while moving the task to the desired list."), - // new ThemedIcon ("dialog-error"), - // Gtk.ButtonsType.CLOSE - // ); - // error_dialog.show_error_details (e.message); - // error_dialog.run (); - // error_dialog.destroy (); - - // } finally { - // Gtk.drag_finish (context, drop_successful, move_successful, time); - // } - // }); - // } - - // return drop_successful; - // } - - // private void on_drag_data_received (Gdk.DragContext context, int x, int y, Gtk.SelectionData selection_data, uint info, uint time) { - // received_drag_data = new Gee.HashMultiMap (); - - // var uri_scheme = "task://"; - // var uris = selection_data.get_uris (); - - // foreach (var uri in uris) { - // string? source_uid = null; - // string? component_uid = null; - - // if (uri.has_prefix (uri_scheme)) { - // var uri_parts = uri.substring (uri_scheme.length).split ("/"); - - // if (uri_parts.length == 2) { - // source_uid = uri_parts[0]; - // component_uid = uri_parts[1]; - // } - // } - - // if (source_uid == null || component_uid == null) { - // warning ("Can't handle drop data: Unexpected uri format: %s", uri); - - // } else if (source_uid == source.uid) { - // debug ("Dropped task onto the same list, so we have nothing to do."); - - // } else { - // received_drag_data.set (source_uid, component_uid); - // } - // } - // } + private void build_drag_and_drop () { + var drop_target = new Gtk.DropTarget (GLib.Type.STRING, Gdk.DragAction.MOVE); + add_controller (drop_target); + + drop_target.drop.connect (on_drag_drop); + drop_target.enter.connect (on_drag_enter); + drop_target.leave.connect (on_drag_leave); + } + + private Gdk.DragAction on_drag_enter (double x, double y) { + warning ("Enter"); + var style_context = get_style_context (); + if (!style_context.has_class ("drop-hover")) { + style_context.add_class ("drop-hover"); + } + + return Gdk.DragAction.MOVE; + } + + private void on_drag_leave () { + warning ("Leave"); + get_style_context ().remove_class ("drop-hover"); + } + + private Gee.HashMultiMap received_drag_data; + + private async bool on_drag_drop_move_tasks () throws Error { + E.SourceRegistry registry = yield Application.model.get_registry (); + var move_successful = true; + + var source_uids = received_drag_data.get_keys (); + foreach (var source_uid in source_uids) { + var src_source = registry.ref_source (source_uid); + + var component_uids = received_drag_data.get (source_uid); + foreach (var component_uid in component_uids) { + if (!yield Application.model.move_task (src_source, source, component_uid)) { + move_successful = false; + } + } + } + return move_successful; + } + + private bool on_drag_drop (GLib.Value value, double x, double y) { + var uri = (string) value; + drag_data_received (uri); + + var drop_successful = false; + var move_successful = false; + if (uri != null) { + drop_successful = true; + + on_drag_drop_move_tasks.begin ((obj, res) => { + try { + move_successful = on_drag_drop_move_tasks.end (res); + + } catch (Error e) { + var error_dialog = new Granite.MessageDialog ( + _("Moving task failed"), + _("There was an error while moving the task to the desired list."), + new ThemedIcon ("dialog-error"), + Gtk.ButtonsType.CLOSE + ); + error_dialog.show_error_details (e.message); + error_dialog.present (); + error_dialog.response.connect (() => { + error_dialog.destroy (); + }); + + } + }); + } + + return drop_successful; + } + + private void drag_data_received (string uri) { + received_drag_data = new Gee.HashMultiMap (); + + var uri_scheme = "task://"; + + string? source_uid = null; + string? component_uid = null; + + if (uri.has_prefix (uri_scheme)) { + var uri_parts = uri.substring (uri_scheme.length).split ("/"); + + if (uri_parts.length == 2) { + source_uid = uri_parts[0]; + component_uid = uri_parts[1]; + } + } + + if (source_uid == null || component_uid == null) { + warning ("Can't handle drop data: Unexpected uri format: %s", uri); + + } else if (source_uid == source.uid) { + debug ("Dropped task onto the same list, so we have nothing to do."); + + } else { + received_drag_data.set (source_uid, component_uid); + } + } public void update_request () { Tasks.Application.set_task_color (source, source_color); diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 49c7757361..d6ad2a9dc7 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -38,7 +38,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Tasks.Widgets.EntryPopover.Location location_popover; private Gtk.Revealer location_popover_revealer; - // private Gtk.EventBox event_box; private Gtk.Stack state_stack; private Gtk.Image icon; private Gtk.CheckButton check; @@ -284,16 +283,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { child = grid }; - // event_box = new Gtk.EventBox () { - // expand = true, - // above_child = false - // }; - // event_box.add_events ( - // Gdk.EventMask.BUTTON_PRESS_MASK | - // Gdk.EventMask.BUTTON_RELEASE_MASK - // ); - // event_box.add (revealer); - child = revealer; margin_start = 12; margin_end = 12; @@ -318,7 +307,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { }); } - // build_drag_and_drop (); + build_drag_and_drop (); var key_controller = new Gtk.EventControllerKey (); add_controller (key_controller); @@ -386,7 +375,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { summary_entry.text = icalcomponent.get_summary () == null ? "" : icalcomponent.get_summary (); // vala-lint=line-length description_textbuffer.text = icalcomponent.get_description () == null ? "" : icalcomponent.get_description (); // vala-lint=line-length due_datetime_popover.value = icalcomponent.get_due ().is_null_time () ? null : Util.ical_to_date_time_local (icalcomponent.get_due ()); // vala-lint=line-length - // location_popover.value = Util.get_ecalcomponent_location (task); + location_popover.value = Util.get_ecalcomponent_location (task); } private void save_task (ECal.Component task) { @@ -410,7 +399,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { ical_task.set_due (new_icaltime); ical_task.set_dtstart (new_icaltime); - // Util.set_ecalcomponent_location (task, location_popover.value); + Util.set_ecalcomponent_location (task, location_popover.value); ical_task.set_summary (summary_entry.text); ical_task.set_description (description_textbuffer.text); @@ -552,50 +541,52 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { return created.is_valid_time (); } - // private void build_drag_and_drop () { - // if (!created || is_scheduled_view) { - // return; - // } - // Gtk.drag_source_set (event_box, Gdk.ModifierType.BUTTON1_MASK, Application.DRAG_AND_DROP_TASK_DATA, Gdk.DragAction.MOVE); - - // event_box.drag_begin.connect (on_drag_begin); - // event_box.drag_data_get.connect (on_drag_data_get); - // event_box.drag_data_delete.connect (on_drag_data_delete); - // } - - // private void on_drag_begin (Gdk.DragContext context) { - // Gtk.Allocation alloc; - // get_allocation (out alloc); - - // var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, alloc.width, alloc.height); - // var cairo_context = new Cairo.Context (surface); - - // var style_context = get_style_context (); - // var had_cards_class = style_context.has_class (Granite.STYLE_CLASS_CARD); - - // style_context.add_class ("drag-active"); - // if (had_cards_class) { - // style_context.remove_class (Granite.STYLE_CLASS_CARD); - // } - // draw_to_cairo_context (cairo_context); - // if (had_cards_class) { - // style_context.add_class (Granite.STYLE_CLASS_CARD); - // } - // style_context.remove_class ("drag-active"); - - // int drag_icon_x, drag_icon_y; - // translate_coordinates (this, 0, 0, out drag_icon_x, out drag_icon_y); - // surface.set_device_offset (-drag_icon_x, -drag_icon_y); - - // Gtk.drag_set_icon_surface (context, surface); - // } - - // private void on_drag_data_get (Gtk.Widget widget, Gdk.DragContext context, Gtk.SelectionData selection_data, uint target_type, uint time) { - // var task_uri = "task://%s/%s".printf (source.uid, task.get_uid ()); - // selection_data.set_uris ({ task_uri }); - // } - - // private void on_drag_data_delete (Gdk.DragContext context) { - // destroy (); - // } + private void build_drag_and_drop () { + if (!created || is_scheduled_view) { + return; + } + + var content = new Gdk.ContentProvider.for_value ("task://%s/%s".printf (source.uid, task.get_uid ())); + var drag_source = new Gtk.DragSource () { + content = content + }; + add_controller (drag_source); + + drag_source.drag_begin.connect (on_drag_begin); + drag_source.drag_end.connect (on_drag_data_delete); + + var drop_target = new Gtk.DropTarget (GLib.Type.STRING, Gdk.DragAction.MOVE); + add_controller (drop_target); + } + + private void on_drag_begin (Gdk.Drag drag) { + Gtk.Allocation alloc; + get_allocation (out alloc); + + // var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, alloc.width, alloc.height); + // var cairo_context = new Cairo.Context (surface); + + unowned var style_context = get_style_context (); + var had_cards_class = style_context.has_class (Granite.STYLE_CLASS_CARD); + + style_context.add_class ("drag-active"); + if (had_cards_class) { + style_context.remove_class (Granite.STYLE_CLASS_CARD); + } + // draw_to_cairo_context (cairo_context); + // if (had_cards_class) { + // style_context.add_class (Granite.STYLE_CLASS_CARD); + // } + // style_context.remove_class ("drag-active"); + + // int drag_icon_x, drag_icon_y; + // translate_coordinates (this, 0, 0, out drag_icon_x, out drag_icon_y); + // surface.set_device_offset (-drag_icon_x, -drag_icon_y); + + // Gtk.drag_set_icon_surface (context, surface); + } + + private void on_drag_data_delete (Gdk.Drag drag, bool delete_data) { + destroy (); + } } From 8f611fee2f70e1014169e92ad8b220747256b1ae Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 00:37:27 +0900 Subject: [PATCH 40/86] Remove redundant code --- src/Application.vala | 4 ---- src/Widgets/TaskRow.vala | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index ba61770703..e0e92ddc0f 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -28,10 +28,6 @@ public class Tasks.Application : Gtk.Application { public static Tasks.TaskModel model; public static bool run_in_background = false; - // public Gtk.DropTarget[] DRAG_AND_DROP_TASK_DATA = { - // { "text/uri-list", Gtk.TargetFlags.SAME_APP | Gtk.TargetFlags.OTHER_WIDGET, 0 } // TODO: TEXT_URI - // }; - public Application () { Object ( application_id: "io.elementary.tasks", diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index d6ad2a9dc7..66784f7a26 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -554,9 +554,6 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { drag_source.drag_begin.connect (on_drag_begin); drag_source.drag_end.connect (on_drag_data_delete); - - var drop_target = new Gtk.DropTarget (GLib.Type.STRING, Gdk.DragAction.MOVE); - add_controller (drop_target); } private void on_drag_begin (Gdk.Drag drag) { From 25bd91e61c5fb704ae7c8c074d202ba3181dd6c5 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 01:17:30 +0900 Subject: [PATCH 41/86] I can't figure out how to do drag and drop, so at least make it look nice --- src/Widgets/SourceRow.vala | 4 +-- src/Widgets/TaskRow.vala | 51 +++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 5e4fda74fa..09361d0c95 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -88,11 +88,11 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { } private void build_drag_and_drop () { - var drop_target = new Gtk.DropTarget (GLib.Type.STRING, Gdk.DragAction.MOVE); + var drop_target = new Gtk.DropTarget (Type.STRING, Gdk.DragAction.MOVE); add_controller (drop_target); drop_target.drop.connect (on_drag_drop); - drop_target.enter.connect (on_drag_enter); + drop_target.motion.connect (on_drag_enter); drop_target.leave.connect (on_drag_leave); } diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 66784f7a26..3c0034b75d 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -49,6 +49,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Gtk.Revealer task_form_revealer; private Gtk.TextBuffer description_textbuffer; + private Gtk.DragSource drag_source; + private TaskRow (ECal.Component task, E.Source source) { Object (task: task, source: source); } @@ -546,44 +548,43 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { return; } - var content = new Gdk.ContentProvider.for_value ("task://%s/%s".printf (source.uid, task.get_uid ())); - var drag_source = new Gtk.DragSource () { - content = content - }; + drag_source = new Gtk.DragSource (); add_controller (drag_source); + drag_source.prepare.connect (on_drag_prepare); drag_source.drag_begin.connect (on_drag_begin); drag_source.drag_end.connect (on_drag_data_delete); } - private void on_drag_begin (Gdk.Drag drag) { - Gtk.Allocation alloc; - get_allocation (out alloc); + private int drag_offset_x; + private int drag_offset_y; + private bool had_cards_class; + + private Gdk.ContentProvider? on_drag_prepare (double x, double y) { + drag_offset_x = (int) x; + drag_offset_y = (int) y; + return new Gdk.ContentProvider.for_value ("task://%s/%s".printf (source.uid, task.get_uid ())); + } - // var surface = new Cairo.ImageSurface (Cairo.Format.ARGB32, alloc.width, alloc.height); - // var cairo_context = new Cairo.Context (surface); + private void on_drag_begin (Gdk.Drag drag) { + drag_source.set_icon (new Gtk.WidgetPaintable (this), drag_offset_x, drag_offset_y); - unowned var style_context = get_style_context (); - var had_cards_class = style_context.has_class (Granite.STYLE_CLASS_CARD); + had_cards_class = has_css_class (Granite.STYLE_CLASS_CARD); - style_context.add_class ("drag-active"); + add_css_class ("drag-active"); if (had_cards_class) { - style_context.remove_class (Granite.STYLE_CLASS_CARD); + remove_css_class (Granite.STYLE_CLASS_CARD); } - // draw_to_cairo_context (cairo_context); - // if (had_cards_class) { - // style_context.add_class (Granite.STYLE_CLASS_CARD); - // } - // style_context.remove_class ("drag-active"); - - // int drag_icon_x, drag_icon_y; - // translate_coordinates (this, 0, 0, out drag_icon_x, out drag_icon_y); - // surface.set_device_offset (-drag_icon_x, -drag_icon_y); - - // Gtk.drag_set_icon_surface (context, surface); } private void on_drag_data_delete (Gdk.Drag drag, bool delete_data) { - destroy (); + remove_css_class ("drag-active"); + if (had_cards_class) { + add_css_class (Granite.STYLE_CLASS_CARD); + } + + if (delete_data) { + destroy (); + } } } From 434c96a72c4c81caf7dbe86e7e105562b9ee27e9 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 01:56:43 +0900 Subject: [PATCH 42/86] Wow it highlights now --- src/Widgets/SourceRow.vala | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 09361d0c95..cc4f8b344f 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -91,24 +91,27 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { var drop_target = new Gtk.DropTarget (Type.STRING, Gdk.DragAction.MOVE); add_controller (drop_target); + drop_target.accept.connect (on_drop_accept); drop_target.drop.connect (on_drag_drop); - drop_target.motion.connect (on_drag_enter); + drop_target.enter.connect (on_drag_enter); drop_target.leave.connect (on_drag_leave); + + } + + private bool on_drop_accept (Gdk.Drop drop) { + return true; } private Gdk.DragAction on_drag_enter (double x, double y) { - warning ("Enter"); - var style_context = get_style_context (); - if (!style_context.has_class ("drop-hover")) { - style_context.add_class ("drop-hover"); + if (!has_css_class ("drop-hover")) { + add_css_class ("drop-hover"); } return Gdk.DragAction.MOVE; } private void on_drag_leave () { - warning ("Leave"); - get_style_context ().remove_class ("drop-hover"); + remove_css_class ("drop-hover"); } private Gee.HashMultiMap received_drag_data; From 8e48a31b90aff53d56415565f99c6315207d6b68 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 02:03:51 +0900 Subject: [PATCH 43/86] Fix dark EntryPopover styles --- data/EntryPopover.css | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data/EntryPopover.css b/data/EntryPopover.css index e19a86f5a4..ea11625452 100644 --- a/data/EntryPopover.css +++ b/data/EntryPopover.css @@ -25,12 +25,12 @@ entry-popover .container { entry-popover menubutton { background: transparent; - color: @SILVER_900; font-size: 0.9em; font-weight: 600; } entry-popover menubutton button.toggle { + color: @SILVER_900; background: transparent; border: none; box-shadow: none; @@ -38,12 +38,18 @@ entry-popover menubutton button.toggle { entry-popover .delete-button { padding: 0.4rem; + color: inherit; } entry-popover.error .container { background: alpha(@error_color, 0.2); } +entry-popover.error menubutton button { + color: @error_color; +} + + entry-popover.error .delete-button { color: @error_color; } From 4ca903c8606a3b3dad18dd44095c7351421a32c9 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 02:07:48 +0900 Subject: [PATCH 44/86] Fix 2 --- data/EntryPopover.css | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/data/EntryPopover.css b/data/EntryPopover.css index ea11625452..a4834108fc 100644 --- a/data/EntryPopover.css +++ b/data/EntryPopover.css @@ -23,29 +23,26 @@ entry-popover .container { background: @SILVER_300; } -entry-popover menubutton { - background: transparent; - font-size: 0.9em; - font-weight: 600; -} - entry-popover menubutton button.toggle { - color: @SILVER_900; background: transparent; border: none; + color: @SILVER_900; + font-size: 0.9em; box-shadow: none; + font-weight: 600; } entry-popover .delete-button { padding: 0.4rem; - color: inherit; + color: @SILVER_900; } + entry-popover.error .container { background: alpha(@error_color, 0.2); } -entry-popover.error menubutton button { +entry-popover.error menubutton button.toggle { color: @error_color; } From 6cb85b63682a56d37351bdd3c9c9fca7ab23ba41 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 12:08:14 +0900 Subject: [PATCH 45/86] Fix drag and drop --- src/MainWindow.vala | 15 +++++++-------- src/Widgets/SourceRow.vala | 5 +++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 2716907e8f..5664b409bd 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -131,24 +131,23 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { task_list_grid_stack = new Gtk.Stack (); var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - css_classes = { Granite.STYLE_CLASS_BACKGROUND } + css_classes = { Granite.STYLE_CLASS_VIEW } }; main_box.append (main_header); main_box.append (task_list_grid_stack); var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL) { - start_child = sidebar, // (sidebar, false, false); - end_child = main_box, // (main_box, true, false); - resize_end_child = true // ??? + start_child = sidebar, + end_child = main_box, + resize_start_child = false, + shrink_end_child = false, + shrink_start_child = false }; child = paned; // We need to hide the title area for the split headerbar - var null_title = new Gtk.Grid () { - visible = false - }; - set_titlebar (null_title); + titlebar = new Gtk.Grid () { visible = false }; var settings = new GLib.Settings ("io.elementary.tasks"); settings.bind ("window-width", this, "default-width", SettingsBindFlags.DEFAULT); diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index cc4f8b344f..29db1fa851 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -88,7 +88,7 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { } private void build_drag_and_drop () { - var drop_target = new Gtk.DropTarget (Type.STRING, Gdk.DragAction.MOVE); + var drop_target = new Gtk.DropTarget (typeof (string), Gdk.DragAction.COPY); add_controller (drop_target); drop_target.accept.connect (on_drop_accept); @@ -107,7 +107,7 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { add_css_class ("drop-hover"); } - return Gdk.DragAction.MOVE; + return Gdk.DragAction.COPY; } private void on_drag_leave () { @@ -135,6 +135,7 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { } private bool on_drag_drop (GLib.Value value, double x, double y) { + warning ("Drop"); var uri = (string) value; drag_data_received (uri); From aaed48a521aa16b5b2a56ccf8fc8da8b81c9ae95 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 12:46:18 +0900 Subject: [PATCH 46/86] An attempt to improve dnd --- src/Widgets/SourceRow.vala | 22 +++++++++------------- src/Widgets/TaskRow.vala | 10 ++++++---- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 29db1fa851..2e3a6c6a95 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -116,10 +116,8 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { private Gee.HashMultiMap received_drag_data; - private async bool on_drag_drop_move_tasks () throws Error { + private async void on_drag_drop_move_tasks () throws Error { E.SourceRegistry registry = yield Application.model.get_registry (); - var move_successful = true; - var source_uids = received_drag_data.get_keys (); foreach (var source_uid in source_uids) { var src_source = registry.ref_source (source_uid); @@ -127,27 +125,26 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { var component_uids = received_drag_data.get (source_uid); foreach (var component_uid in component_uids) { if (!yield Application.model.move_task (src_source, source, component_uid)) { - move_successful = false; + warning ("Couldn't move task %s to %s", component_uid, source.uid); } } } - return move_successful; } private bool on_drag_drop (GLib.Value value, double x, double y) { warning ("Drop"); - var uri = (string) value; - drag_data_received (uri); + + parse_data ((string) value); + var drop_successful = false; - var move_successful = false; - if (uri != null) { + if (received_drag_data != null && received_drag_data.size > 0) { drop_successful = true; on_drag_drop_move_tasks.begin ((obj, res) => { try { - move_successful = on_drag_drop_move_tasks.end (res); - + on_drag_drop_move_tasks.end (res); + warning ("Ended transferring tasks"); } catch (Error e) { var error_dialog = new Granite.MessageDialog ( _("Moving task failed"), @@ -160,7 +157,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { error_dialog.response.connect (() => { error_dialog.destroy (); }); - } }); } @@ -168,7 +164,7 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { return drop_successful; } - private void drag_data_received (string uri) { + private void parse_data (string uri) { received_drag_data = new Gee.HashMultiMap (); var uri_scheme = "task://"; diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 3c0034b75d..56fe829958 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -563,6 +563,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { private Gdk.ContentProvider? on_drag_prepare (double x, double y) { drag_offset_x = (int) x; drag_offset_y = (int) y; + return new Gdk.ContentProvider.for_value ("task://%s/%s".printf (source.uid, task.get_uid ())); } @@ -578,13 +579,14 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } private void on_drag_data_delete (Gdk.Drag drag, bool delete_data) { + warning ("Data delete"); + + unparent (); + destroy (); + remove_css_class ("drag-active"); if (had_cards_class) { add_css_class (Granite.STYLE_CLASS_CARD); } - - if (delete_data) { - destroy (); - } } } From b5944d5f2448e91d5d7c070481159f8dd1ee0e05 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 12:54:44 +0900 Subject: [PATCH 47/86] Fix dnd --- src/Widgets/TaskRow.vala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 56fe829958..ab78049d9b 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -579,9 +579,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } private void on_drag_data_delete (Gdk.Drag drag, bool delete_data) { - warning ("Data delete"); - - unparent (); + ((Gtk.ListBox) parent).remove (this); destroy (); remove_css_class ("drag-active"); From a8e50aaaf7d2c3ffadde3cdf1b852bd85f4f035b Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 12:57:57 +0900 Subject: [PATCH 48/86] Remove debug --- src/Widgets/SourceRow.vala | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 2e3a6c6a95..39572107a5 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -132,8 +132,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { } private bool on_drag_drop (GLib.Value value, double x, double y) { - warning ("Drop"); - parse_data ((string) value); @@ -144,7 +142,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { on_drag_drop_move_tasks.begin ((obj, res) => { try { on_drag_drop_move_tasks.end (res); - warning ("Ended transferring tasks"); } catch (Error e) { var error_dialog = new Granite.MessageDialog ( _("Moving task failed"), From d3c6df932bd354e705923619b4d5171c84afcad4 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 13:54:11 +0900 Subject: [PATCH 49/86] Some styles fixes --- src/Widgets/SourceRow.vala | 11 +++-------- src/Widgets/TaskRow.vala | 7 +++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 39572107a5..6d623a1d80 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -21,8 +21,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { public E.Source source { get; construct; } - private static Gtk.CssProvider listrow_provider; - private Gtk.Grid source_color; private Gtk.Image status_image; private Gtk.Label display_name_label; @@ -34,17 +32,16 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { } static construct { - listrow_provider = new Gtk.CssProvider (); - listrow_provider.load_from_resource ("io/elementary/tasks/SourceRow.css"); + var style_provider = new Gtk.CssProvider (); + style_provider.load_from_resource ("io/elementary/tasks/SourceRow.css"); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } construct { source_color = new Gtk.Grid () { valign = Gtk.Align.CENTER }; - source_color.add_css_class ("source-color"); - source_color.get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); display_name_label = new Gtk.Label (source.display_name) { halign = Gtk.Align.START, @@ -55,7 +52,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { status_image = new Gtk.Image () { pixel_size = 16 }; - status_image.get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); var spinner = new Gtk.Spinner () { spinning = true, @@ -80,7 +76,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { }; child = revealer; - get_style_context ().add_provider (listrow_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); build_drag_and_drop (); diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index ab78049d9b..65c7a75be7 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -93,7 +93,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { icon.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); check = new Gtk.CheckButton () { - valign = Gtk.Align.CENTER + valign = Gtk.Align.CENTER, + css_classes = { "task-row-check" } }; state_stack = new Gtk.Stack () { @@ -425,7 +426,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { public void update_request () { if (!is_scheduled_view) { - Tasks.Application.set_task_color (source, check); + // FIXME: check.get_first_child () is used because Gtk.StyleContext.add_provider works differently in Gtk4 + // Also, it's deprecated now, so we need to use Gtk.StyleContext.add_provider_for_display + Tasks.Application.set_task_color (source, check.get_first_child ()); } var default_due_datetime = new DateTime.now_local ().add_hours (1); From 0b7c6947e2dc2cc7bfea23b2ffb53e755360a03d Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 13:56:28 +0900 Subject: [PATCH 50/86] Use SizeGroup --- src/Widgets/TaskRow.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 65c7a75be7..ece0fe5f3d 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -237,11 +237,15 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { child = description_textview }; + var buttons_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL); + var cancel_button = new Gtk.Button.with_label (_("Cancel")); + buttons_size_group.add_widget (cancel_button); var save_button = new Gtk.Button.with_label (created ? _("Save Changes") : _("Add Task")) { css_classes = { Granite.STYLE_CLASS_SUGGESTED_ACTION } }; + buttons_size_group.add_widget (save_button); var right_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { halign = Gtk.Align.END @@ -300,6 +304,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { halign = Gtk.Align.START, css_classes = { Granite.STYLE_CLASS_DESTRUCTIVE_ACTION } }; + buttons_size_group.add_widget (delete_button); button_grid.attach (delete_button, 0, 0); From 944223ed8b7bf9e426608e6499ed454c6d99f768 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 14:02:55 +0900 Subject: [PATCH 51/86] Add ButtonBox style --- data/ButtonBox.css | 23 +++++++++++++++++++++++ data/gresource.xml | 1 + src/Application.vala | 4 ++++ src/Widgets/TaskRow.vala | 3 ++- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 data/ButtonBox.css diff --git a/data/ButtonBox.css b/data/ButtonBox.css new file mode 100644 index 0000000000..d05cf9b100 --- /dev/null +++ b/data/ButtonBox.css @@ -0,0 +1,23 @@ +/* +* Copyright 2023 elementary, Inc. (https://elementary.io) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 3 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* 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 along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +.button-box button { + min-width: 86px; /* https://github.com/elementary/granite/issues/577#issuecomment-1318979272 */ +} diff --git a/data/gresource.xml b/data/gresource.xml index 6a9d485e7d..8ffd728abb 100644 --- a/data/gresource.xml +++ b/data/gresource.xml @@ -2,6 +2,7 @@ LocationMarker.svg + ButtonBox.css EditableLabel.css EntryPopover.css SourceRow.css diff --git a/src/Application.vala b/src/Application.vala index e0e92ddc0f..cbcc062cc2 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -80,6 +80,10 @@ public class Tasks.Application : Gtk.Application { granite_settings.notify["prefers-color-scheme"].connect (() => { gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; }); + + var button_box_style_provider = new Gtk.CssProvider (); + button_box_style_provider.load_from_resource ("io/elementary/tasks/ButtonBox.css"); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), button_box_style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } active_window.present (); diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index ece0fe5f3d..85e7fac479 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -255,7 +255,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var button_grid = new Gtk.Grid () { margin_top = 12, - column_homogeneous = true + column_homogeneous = true, + css_classes = { "button-box" } }; button_grid.attach (right_buttons_box, 1, 0); From 2851b1030a404ce375c13a2b659dfe548cab3397 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 14:04:14 +0900 Subject: [PATCH 52/86] Fix style class --- src/MainWindow.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 5664b409bd..acf245e466 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -131,7 +131,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { task_list_grid_stack = new Gtk.Stack (); var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - css_classes = { Granite.STYLE_CLASS_VIEW } + css_classes = { Granite.STYLE_CLASS_BACKGROUND } }; main_box.append (main_header); main_box.append (task_list_grid_stack); From 5d61e2794a56743d960c06b4f4ce5e3df148b6e2 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 14:21:30 +0900 Subject: [PATCH 53/86] Move placeholder --- src/Widgets/TaskListGrid.vala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 95bf690a9a..d60c4b661d 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -58,10 +58,6 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { css_classes = { Granite.STYLE_CLASS_FLAT, Granite.STYLE_CLASS_DIM_LABEL } }; - var placeholder = new Gtk.Label (_("No Tasks")) { - css_classes = { Granite.STYLE_CLASS_DIM_LABEL, Granite.STYLE_CLASS_H2_LABEL} - }; - add_task_list = new Gtk.ListBox () { margin_top = 24, selection_mode = Gtk.SelectionMode.SINGLE, @@ -93,13 +89,17 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }); add_task_list.append (add_task_row); + var placeholder = new Gtk.Label (_("No Tasks")) { + css_classes = { Granite.STYLE_CLASS_DIM_LABEL, Granite.STYLE_CLASS_H2_LABEL} + }; + task_list = new Gtk.ListBox () { selection_mode = Gtk.SelectionMode.SINGLE, activate_on_single_click = true, css_classes = { Granite.STYLE_CLASS_BACKGROUND } }; - task_list.set_placeholder (placeholder); task_list.set_sort_func (sort_function); + task_list.set_placeholder (placeholder); var scrolled_window = new Gtk.ScrolledWindow () { hexpand = true, From 0035a09aa3137c23c652c409f63b478a627cab70 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 16:14:04 +0900 Subject: [PATCH 54/86] Fix lint --- meson.build | 2 +- src/MainWindow.vala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 5b0d8dffbd..c2dbeea060 100644 --- a/meson.build +++ b/meson.build @@ -35,7 +35,7 @@ tasks_deps = [ libecal_dep, dependency('libedataserver-1.2'), dependency('libgeoclue-2.0'), - # dependency('shumate-0-.0'), + # dependency('shumate-1.0'), dependency('libical-glib') ] diff --git a/src/MainWindow.vala b/src/MainWindow.vala index acf245e466..a811e2043b 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -147,7 +147,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { child = paned; // We need to hide the title area for the split headerbar - titlebar = new Gtk.Grid () { visible = false }; + titlebar = new Gtk.Grid () { visible = false }; var settings = new GLib.Settings ("io.elementary.tasks"); settings.bind ("window-width", this, "default-width", SettingsBindFlags.DEFAULT); From 5ff81bc8ca22fa5999355c0bd61c7d8a21f7a880 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 17:12:36 +0900 Subject: [PATCH 55/86] Don't remove placeholder from task_list --- src/Widgets/TaskListGrid.vala | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index d60c4b661d..d383e724cc 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -24,6 +24,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { private EditableLabel editable_title; private Gtk.ListBox add_task_list; + private Gtk.Label placeholder; private Gtk.ListBox task_list; private bool is_gtasks; @@ -89,7 +90,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }); add_task_list.append (add_task_row); - var placeholder = new Gtk.Label (_("No Tasks")) { + placeholder = new Gtk.Label (_("No Tasks")) { css_classes = { Granite.STYLE_CLASS_DIM_LABEL, Granite.STYLE_CLASS_H2_LABEL} }; @@ -192,11 +193,18 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } private void set_view_for_query (string query) { - unowned var child = task_list.get_first_child (); + Gtk.Widget[] children_for_removal = {}; + unowned var child = get_first_child (); while (child != null) { - task_list.remove (child); + if (child != placeholder) { + children_for_removal += child; + } + + child = child.get_next_sibling (); + } - child = task_list.get_first_child (); + for (int i = 0; i < children_for_removal.length; i++) { + children_for_removal[i].destroy (); } if (view != null) { From a812171f2b1ffacc04280840d71222514c40d1a6 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 20:13:08 +0900 Subject: [PATCH 56/86] Remove children from task_list --- src/Widgets/TaskListGrid.vala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index d383e724cc..f16a1ca6fa 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -194,9 +194,10 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { private void set_view_for_query (string query) { Gtk.Widget[] children_for_removal = {}; - unowned var child = get_first_child (); + unowned var child = task_list.get_first_child (); while (child != null) { if (child != placeholder) { + var a = (Widgets.TaskRow) child; children_for_removal += child; } @@ -204,6 +205,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } for (int i = 0; i < children_for_removal.length; i++) { + task_list.remove (children_for_removal[i]); children_for_removal[i].destroy (); } @@ -377,7 +379,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } private void on_tasks_modified (Gee.Collection tasks) { - Tasks.Widgets.TaskRow task_row = null; + unowned Tasks.Widgets.TaskRow task_row = null; var row_index = 0; do { From b00ec0b777f6a834ded8b596fba859e93a89e85d Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 20:17:12 +0900 Subject: [PATCH 57/86] Remove children from box too --- src/Widgets/ScheduledTaskListGrid.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index c5aeb8fcda..5fd0f3a516 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -59,6 +59,7 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { } for (int i = 0; i < children_for_removal.length; i++) { + remove (children_for_removal[i]); children_for_removal[i].destroy (); } From 9ad01350d302c6e2f845152ecf1edde17089af28 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 6 Jun 2023 20:47:45 +0900 Subject: [PATCH 58/86] Try to fix dnd --- src/Widgets/SourceRow.vala | 1 - src/Widgets/TaskRow.vala | 25 ++++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index 6d623a1d80..e6f69c1b74 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -129,7 +129,6 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { private bool on_drag_drop (GLib.Value value, double x, double y) { parse_data ((string) value); - var drop_successful = false; if (received_drag_data != null && received_drag_data.size > 0) { drop_successful = true; diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 85e7fac479..c36f45ad50 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -562,12 +562,14 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { drag_source.prepare.connect (on_drag_prepare); drag_source.drag_begin.connect (on_drag_begin); - drag_source.drag_end.connect (on_drag_data_delete); + drag_source.drag_cancel.connect (on_drag_cancel); + drag_source.drag_end.connect (on_drag_end); } private int drag_offset_x; private int drag_offset_y; private bool had_cards_class; + private bool is_canceled; private Gdk.ContentProvider? on_drag_prepare (double x, double y) { drag_offset_x = (int) x; @@ -580,6 +582,7 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { drag_source.set_icon (new Gtk.WidgetPaintable (this), drag_offset_x, drag_offset_y); had_cards_class = has_css_class (Granite.STYLE_CLASS_CARD); + is_canceled = false; add_css_class ("drag-active"); if (had_cards_class) { @@ -587,13 +590,21 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { } } - private void on_drag_data_delete (Gdk.Drag drag, bool delete_data) { - ((Gtk.ListBox) parent).remove (this); - destroy (); + private bool on_drag_cancel (Gdk.Drag drag, Gdk.DragCancelReason reason) { + is_canceled = true; - remove_css_class ("drag-active"); - if (had_cards_class) { - add_css_class (Granite.STYLE_CLASS_CARD); + return true; + } + + private void on_drag_end (Gdk.Drag drag, bool delete_data) { + if (is_canceled) { + remove_css_class ("drag-active"); + if (had_cards_class) { + add_css_class (Granite.STYLE_CLASS_CARD); + } + } else { + ((Gtk.ListBox) parent).remove (this); + destroy (); } } } From 2804f6d742f7364dd02d8905b76c26b568af5783 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sat, 10 Jun 2023 15:38:56 +0900 Subject: [PATCH 59/86] Fix spacing --- src/Widgets/ScheduledTaskListGrid.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Widgets/ScheduledTaskListGrid.vala b/src/Widgets/ScheduledTaskListGrid.vala index 5fd0f3a516..bde731f5fc 100644 --- a/src/Widgets/ScheduledTaskListGrid.vala +++ b/src/Widgets/ScheduledTaskListGrid.vala @@ -115,7 +115,6 @@ public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { }; orientation = Gtk.Orientation.VERTICAL; - spacing = 12; append (scheduled_title); append (scrolled_window); From 25a4976a145f5a58cc2c60213821f750e9e5692f Mon Sep 17 00:00:00 2001 From: lenemter Date: Sat, 10 Jun 2023 15:41:03 +0900 Subject: [PATCH 60/86] Fix "Today" label alignment --- src/Widgets/EntryPopover/DateTime.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/EntryPopover/DateTime.vala b/src/Widgets/EntryPopover/DateTime.vala index 39e451ea83..5ccee25e4a 100644 --- a/src/Widgets/EntryPopover/DateTime.vala +++ b/src/Widgets/EntryPopover/DateTime.vala @@ -55,7 +55,7 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic { }; var today_box = new Widgets.PopoverButton (); - today_box.append (new Gtk.Label (_("Today")) { hexpand = true, justify = Gtk.Justification.CENTER }); + today_box.append (new Gtk.Label (_("Today"))); var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_top = 3 From 7bafaecc4e7ce66dd0dde04eece1e6eb564dd583 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sun, 9 Jul 2023 00:57:43 +0900 Subject: [PATCH 61/86] Fix merge --- src/Application.vala | 4 +-- src/MainWindow.vala | 6 ++-- src/Widgets/ScheduledRow.vala | 7 ----- src/Widgets/ScheduledTaskListBox.vala | 40 --------------------------- src/Widgets/SourceRow.vala | 31 --------------------- src/Widgets/TaskListGrid.vala | 29 ------------------- src/Widgets/TaskRow.vala | 33 ---------------------- 7 files changed, 4 insertions(+), 146 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 6207ec03a0..ea24ff1f1d 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -53,8 +53,6 @@ public class Tasks.Application : Gtk.Application { protected override void startup () { base.startup (); - Hdy.init (); - unowned var granite_settings = Granite.Settings.get_default (); unowned var gtk_settings = Gtk.Settings.get_default (); @@ -92,7 +90,7 @@ public class Tasks.Application : Gtk.Application { if (active_window == null) { model.start.begin (); - var main_window = new MainWindow (this); + new MainWindow (this); unowned var granite_settings = Granite.Settings.get_default (); unowned var gtk_settings = Gtk.Settings.get_default (); diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 50750e436e..0b0c041719 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -138,7 +138,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { settings.bind ("window-height", this, "default-height", SettingsBindFlags.DEFAULT); settings.bind ("window-maximized", this, "maximized", SettingsBindFlags.DEFAULT); - delete_event.connect (() => { + close_request.connect (() => { ((Application)application).request_background.begin (() => destroy ()); return Gdk.EVENT_STOP; @@ -237,9 +237,9 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { ((SimpleAction) lookup_action (ACTION_DELETE_SELECTED_LIST)).set_enabled (Tasks.Application.model.is_remove_task_list_supported (source)); } else if (row is Tasks.Widgets.ScheduledRow) { - var scheduled_task_list_grid = (Tasks.Widgets.ScheduledTaskListGrid) task_list_grid_stack.get_child_by_name (SCHEDULED_LIST_UID); + var scheduled_task_list_grid = (Tasks.Widgets.ScheduledTaskListBox) task_list_grid_stack.get_child_by_name (SCHEDULED_LIST_UID); if (scheduled_task_list_grid == null) { - scheduled_task_list_grid = new Tasks.Widgets.ScheduledTaskListGrid (Tasks.Application.model); + scheduled_task_list_grid = new Tasks.Widgets.ScheduledTaskListBox (Tasks.Application.model); task_list_grid_stack.add_named (scheduled_task_list_grid, SCHEDULED_LIST_UID); } diff --git a/src/Widgets/ScheduledRow.vala b/src/Widgets/ScheduledRow.vala index 6dff660bc6..645dc179f0 100644 --- a/src/Widgets/ScheduledRow.vala +++ b/src/Widgets/ScheduledRow.vala @@ -19,16 +19,9 @@ public class Tasks.Widgets.ScheduledRow : Gtk.ListBoxRow { margin_start = 12, margin_end = 6 }; -<<<<<<< HEAD box.append (icon); box.append (display_name_label); child = box; -======= - box.add (icon); - box.add (display_name_label); - - add (box); ->>>>>>> master } } diff --git a/src/Widgets/ScheduledTaskListBox.vala b/src/Widgets/ScheduledTaskListBox.vala index 558c573d69..162e25d9b1 100644 --- a/src/Widgets/ScheduledTaskListBox.vala +++ b/src/Widgets/ScheduledTaskListBox.vala @@ -1,32 +1,9 @@ /* -<<<<<<< HEAD:src/Widgets/ScheduledTaskListGrid.vala -* Copyright 2019-2023 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* 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 along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ - -public class Tasks.Widgets.ScheduledTaskListGrid : Gtk.Box { -======= * Copyright 2019-2023 elementary, Inc. (https://elementary.io) * SPDX-License-Identifier: GPL-3.0-or-later */ public class Tasks.Widgets.ScheduledTaskListBox : Gtk.Box { ->>>>>>> master:src/Widgets/ScheduledTaskListBox.vala private Gee.Map views; private const string QUERY = "AND (NOT is-completed?) (has-start?)"; @@ -56,13 +33,9 @@ public class Tasks.Widgets.ScheduledTaskListBox : Gtk.Box { } private void remove_view (E.Source source) { -<<<<<<< HEAD:src/Widgets/ScheduledTaskListGrid.vala Gtk.Widget[] children_for_removal = {}; unowned var child = get_first_child (); while (child != null) { -======= - foreach (unowned Gtk.Widget child in task_list.get_children ()) { ->>>>>>> master:src/Widgets/ScheduledTaskListBox.vala if (child is Tasks.Widgets.TaskRow && ((Tasks.Widgets.TaskRow) child).source == source) { children_for_removal += child; } @@ -119,29 +92,16 @@ public class Tasks.Widgets.ScheduledTaskListBox : Gtk.Box { task_list.set_header_func (header_function); task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); -<<<<<<< HEAD:src/Widgets/ScheduledTaskListGrid.vala var scrolled_window = new Gtk.ScrolledWindow () { hexpand = true, vexpand = true, hscrollbar_policy = Gtk.PolicyType.NEVER, child = task_list -======= - var scrolled_window = new Gtk.ScrolledWindow (null, null) { - hexpand = true, - vexpand = true, - hscrollbar_policy = Gtk.PolicyType.NEVER ->>>>>>> master:src/Widgets/ScheduledTaskListBox.vala }; orientation = Gtk.Orientation.VERTICAL; -<<<<<<< HEAD:src/Widgets/ScheduledTaskListGrid.vala append (scheduled_title); append (scrolled_window); -======= - add (scheduled_title); - add (scrolled_window); - show_all (); ->>>>>>> master:src/Widgets/ScheduledTaskListBox.vala task_list.row_activated.connect (on_row_activated); diff --git a/src/Widgets/SourceRow.vala b/src/Widgets/SourceRow.vala index f8b85b2523..4a33b55f28 100644 --- a/src/Widgets/SourceRow.vala +++ b/src/Widgets/SourceRow.vala @@ -1,28 +1,7 @@ /* -<<<<<<< HEAD -* Copyright 2019-2023 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* 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 along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ -======= * Copyright 2019-2023 elementary, Inc. (https://elementary.io) * SPDX-License-Identifier: GPL-3.0-or-later */ ->>>>>>> master public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { public E.Source source { get; construct; } @@ -72,24 +51,14 @@ public class Tasks.Widgets.SourceRow : Gtk.ListBoxRow { margin_start = 12, margin_end = 6 }; -<<<<<<< HEAD box.append (source_color); box.append (display_name_label); box.append (status_stack); -======= - box.add (source_color); - box.add (display_name_label); - box.add (status_stack); ->>>>>>> master revealer = new Gtk.Revealer () { reveal_child = true, child = box }; -<<<<<<< HEAD -======= - revealer.add (box); ->>>>>>> master child = revealer; diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 8fbd54ba58..e3059be38c 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -1,28 +1,7 @@ /* -<<<<<<< HEAD -* Copyright 2019-2023 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* 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 along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ -======= * Copyright 2019-2023 elementary, Inc. (https://elementary.io) * SPDX-License-Identifier: GPL-3.0-or-later */ ->>>>>>> master public class Tasks.Widgets.TaskListGrid : Gtk.Grid { public E.Source source { get; construct; } @@ -108,18 +87,11 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { task_list.set_sort_func (sort_function); task_list.set_placeholder (placeholder); -<<<<<<< HEAD var scrolled_window = new Gtk.ScrolledWindow () { hexpand = true, vexpand = true, hscrollbar_policy = Gtk.PolicyType.NEVER, child = task_list -======= - var scrolled_window = new Gtk.ScrolledWindow (null, null) { - hexpand = true, - vexpand = true, - hscrollbar_policy = Gtk.PolicyType.NEVER ->>>>>>> master }; column_spacing = 12; @@ -210,7 +182,6 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { unowned var child = task_list.get_first_child (); while (child != null) { if (child != placeholder) { - var a = (Widgets.TaskRow) child; children_for_removal += child; } diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 9c4290996b..561eecb66d 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -197,26 +197,15 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { child = description_label }; -<<<<<<< HEAD var task_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 3); task_box.append (due_datetime_popover_revealer); task_box.append (location_popover_revealer); task_box.append (description_label_revealer); -======= - var task_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); - task_box.add (due_datetime_popover_revealer); - task_box.add (location_popover_revealer); - task_box.add (description_label_revealer); ->>>>>>> master task_detail_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_UP, child = task_box }; -<<<<<<< HEAD -======= - task_detail_revealer.add (task_box); ->>>>>>> master var description_textview = new Granite.HyperTextView () { // border_width = 12, @@ -260,22 +249,13 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { margin_top = 6, margin_bottom = 6 }; -<<<<<<< HEAD form_box.append (description_frame); form_box.append (button_grid); -======= - form_box.add (description_frame); - form_box.add (button_box); ->>>>>>> master task_form_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN, child = form_box }; -<<<<<<< HEAD -======= - task_form_revealer.add (form_box); ->>>>>>> master var grid = new Gtk.Grid () { margin_top = 6, @@ -296,22 +276,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { child = grid }; -<<<<<<< HEAD child = revealer; margin_start = 12; margin_end = 12; -======= - event_box = new Gtk.EventBox () { - hexpand = true, - vexpand = true, - above_child = false - }; - event_box.add_events ( - Gdk.EventMask.BUTTON_PRESS_MASK | - Gdk.EventMask.BUTTON_RELEASE_MASK - ); - event_box.add (revealer); ->>>>>>> master add_css_class (Granite.STYLE_CLASS_ROUNDED); From af71299252c5b4b4ee99653abfcca556574482a4 Mon Sep 17 00:00:00 2001 From: lenemter Date: Sat, 5 Aug 2023 00:13:59 +0900 Subject: [PATCH 62/86] Don't use `css_classes` --- src/MainWindow.vala | 27 +++++++------- src/Widgets/EditableLabel.vala | 4 +-- src/Widgets/EntryPopover/Generic.vala | 14 ++++---- src/Widgets/ListSettingsPopover.vala | 51 ++++++++++++++++----------- src/Widgets/PopoverButton.vala | 5 ++- src/Widgets/TaskListGrid.vala | 24 +++++++------ src/Widgets/TaskRow.vala | 17 +++++---- 7 files changed, 75 insertions(+), 67 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 0b0c041719..b0f357d50d 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -54,9 +54,10 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var sidebar_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), - show_title_buttons = false, - css_classes = { Granite.STYLE_CLASS_DEFAULT_DECORATION, Granite.STYLE_CLASS_FLAT } + show_title_buttons = false }; + sidebar_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); + sidebar_header.add_css_class (Granite.STYLE_CLASS_FLAT); sidebar_header.pack_start (new Gtk.WindowControls (Gtk.PackType.START)); var scrolledwindow = new Gtk.ScrolledWindow () { @@ -71,7 +72,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var online_accounts_button = new Widgets.PopoverButton (); online_accounts_button.append (new Gtk.Label (_("Online Accounts Settings…"))); - var add_tasklist_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 3) { + var add_tasklist_box = new Gtk.Box (VERTICAL, 3) { margin_top = 3, margin_bottom = 3 }; @@ -93,30 +94,28 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { child = add_tasklist_button_box }; - var actionbar = new Gtk.ActionBar () { - css_classes = { Granite.STYLE_CLASS_FLAT } - }; + var actionbar = new Gtk.ActionBar (); + actionbar.add_css_class (Granite.STYLE_CLASS_FLAT); actionbar.pack_start (add_tasklist_button); - var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - css_classes = { Granite.STYLE_CLASS_SIDEBAR } - }; + var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + sidebar.add_css_class (Granite.STYLE_CLASS_SIDEBAR); sidebar.append (sidebar_header); sidebar.append (scrolledwindow); sidebar.append (actionbar); var main_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), - show_title_buttons = false, - css_classes = { Granite.STYLE_CLASS_DEFAULT_DECORATION, Granite.STYLE_CLASS_FLAT } + show_title_buttons = false }; + main_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); + main_header.add_css_class (Granite.STYLE_CLASS_FLAT); main_header.pack_end (new Gtk.WindowControls (Gtk.PackType.END)); task_list_grid_stack = new Gtk.Stack (); - var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - css_classes = { Granite.STYLE_CLASS_BACKGROUND } - }; + var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + main_box.add_css_class (Granite.STYLE_CLASS_BACKGROUND); main_box.append (main_header); main_box.append (task_list_grid_stack); diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index 503d64f85f..d74deeeb2e 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -53,9 +53,9 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { var edit_button = new Gtk.Button () { icon_name = "edit-symbolic", - tooltip_text = _("Edit…"), - css_classes = { Granite.STYLE_CLASS_FLAT } + tooltip_text = _("Edit…") }; + edit_button.add_css_class (Granite.STYLE_CLASS_FLAT); var button_revealer = new Gtk.Revealer () { valign = Gtk.Align.CENTER, diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 831ee1e0a6..941071799a 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -50,14 +50,15 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { popover_button = new Gtk.MenuButton () { popover = popover, - child = popover_button_box, - css_classes = { Granite.STYLE_CLASS_FLAT } + child = popover_button_box }; + popover_button.add_css_class (Granite.STYLE_CLASS_FLAT); var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic") { - tooltip_text = _("Remove"), - css_classes = { Granite.STYLE_CLASS_FLAT, "delete-button" } + tooltip_text = _("Remove") }; + delete_button.add_css_class (Granite.STYLE_CLASS_FLAT); + delete_button.add_css_class ("delete-button"); var delete_button_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.SLIDE_RIGHT, @@ -65,9 +66,8 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { child = delete_button }; - var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) { - css_classes = { "container" } - }; + var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); + button_box.add_css_class ("container"); button_box.append (popover_button); button_box.append (delete_button_revealer); button_box.set_parent (this); diff --git a/src/Widgets/ListSettingsPopover.vala b/src/Widgets/ListSettingsPopover.vala index 048d4b1204..5063e2532e 100644 --- a/src/Widgets/ListSettingsPopover.vala +++ b/src/Widgets/ListSettingsPopover.vala @@ -25,55 +25,64 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover { construct { autohide = true; - color_button_blue = new Gtk.CheckButton () { - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "blue" } - }; + color_button_blue = new Gtk.CheckButton (); + color_button_blue.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_blue.add_css_class ("blue"); color_button_mint = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "mint" } + group = color_button_blue }; + color_button_mint.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_mint.add_css_class ("mint"); color_button_green = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "green" } + group = color_button_blue }; + color_button_green.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_green.add_css_class ("green"); color_button_yellow = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "yellow" } + group = color_button_blue }; + color_button_yellow.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_yellow.add_css_class ("yellow"); color_button_orange = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "orange" } + group = color_button_blue }; + color_button_orange.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_orange.add_css_class ("orange"); color_button_red = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "red" } + group = color_button_blue }; + color_button_red.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_red.add_css_class ("red"); color_button_pink = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "pink" } + group = color_button_blue }; + color_button_pink.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_pink.add_css_class ("pink"); color_button_purple = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "purple" } + group = color_button_blue }; + color_button_purple.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_purple.add_css_class ("purple"); color_button_brown = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "brown" } + group = color_button_blue }; + color_button_brown.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_brown.add_css_class ("brown"); color_button_slate = new Gtk.CheckButton () { - group = color_button_blue, - css_classes = { Granite.STYLE_CLASS_COLOR_BUTTON, "slate" } + group = color_button_blue }; + color_button_slate.add_css_class (Granite.STYLE_CLASS_COLOR_BUTTON); + color_button_slate.add_css_class ("slate"); // FIXME: this CheckButton is unused color_button_none = new Gtk.CheckButton () { diff --git a/src/Widgets/PopoverButton.vala b/src/Widgets/PopoverButton.vala index 28b485d2dd..379bbcef20 100644 --- a/src/Widgets/PopoverButton.vala +++ b/src/Widgets/PopoverButton.vala @@ -22,9 +22,8 @@ class Tasks.Widgets.PopoverButton : Gtk.Box { public signal void clicked (); construct { - orientation = Gtk.Orientation.HORIZONTAL; - spacing = 0; - css_classes = { Granite.STYLE_CLASS_MENUITEM }; + orientation = HORIZONTAL; + add_css_class (Granite.STYLE_CLASS_MENUITEM); var gesture_click = new Gtk.GestureClick (); add_controller (gesture_click); diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index e3059be38c..de250e4a87 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -28,9 +28,10 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { editable_title = new EditableLabel () { margin_start = 24, - hexpand = true, - css_classes = { Granite.STYLE_CLASS_H1_LABEL, Granite.STYLE_CLASS_ACCENT } + hexpand = true }; + editable_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); + editable_title.add_css_class (Granite.STYLE_CLASS_ACCENT); var list_settings_popover = new Tasks.Widgets.ListSettingsPopover (source); @@ -40,16 +41,17 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { valign = Gtk.Align.CENTER, hexpand = false, icon_name = "view-more-symbolic", - tooltip_text = _("Edit Name and Appearance"), - css_classes = { Granite.STYLE_CLASS_FLAT, Granite.STYLE_CLASS_DIM_LABEL } + tooltip_text = _("Edit Name and Appearance") }; + settings_button.add_css_class (Granite.STYLE_CLASS_FLAT); + settings_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); add_task_list = new Gtk.ListBox () { margin_top = 24, selection_mode = Gtk.SelectionMode.SINGLE, - activate_on_single_click = true, - css_classes = { Granite.STYLE_CLASS_BACKGROUND } + activate_on_single_click = true }; + add_task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); var add_task_row = new Tasks.Widgets.TaskRow.for_source (source); add_task_row.unselect.connect (on_row_unselect); @@ -75,15 +77,15 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }); add_task_list.append (add_task_row); - placeholder = new Gtk.Label (_("No Tasks")) { - css_classes = { Granite.STYLE_CLASS_DIM_LABEL, Granite.STYLE_CLASS_H2_LABEL} - }; + placeholder = new Gtk.Label (_("No Tasks")); + placeholder.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); task_list = new Gtk.ListBox () { selection_mode = Gtk.SelectionMode.SINGLE, - activate_on_single_click = true, - css_classes = { Granite.STYLE_CLASS_BACKGROUND } + activate_on_single_click = true }; + task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); task_list.set_sort_func (sort_function); task_list.set_placeholder (placeholder); diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 561eecb66d..124538039b 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -78,9 +78,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { icon.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); check = new Gtk.CheckButton () { - valign = Gtk.Align.CENTER, - css_classes = { "task-row-check" } + valign = Gtk.Align.CENTER }; + check.add_css_class ("task-row-check"); state_stack = new Gtk.Stack () { transition_type = Gtk.StackTransitionType.CROSSFADE @@ -227,9 +227,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var cancel_button = new Gtk.Button.with_label (_("Cancel")); buttons_size_group.add_widget (cancel_button); - var save_button = new Gtk.Button.with_label (created ? _("Save Changes") : _("Add Task")) { - css_classes = { Granite.STYLE_CLASS_SUGGESTED_ACTION } - }; + var save_button = new Gtk.Button.with_label (created ? _("Save Changes") : _("Add Task")); + save_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); buttons_size_group.add_widget (save_button); var right_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { @@ -240,9 +239,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { var button_grid = new Gtk.Grid () { margin_top = 12, - column_homogeneous = true, - css_classes = { "button-box" } + column_homogeneous = true }; + button_grid.add_css_class ("button-box"); button_grid.attach (right_buttons_box, 1, 0); var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12) { @@ -287,9 +286,9 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { state_stack.visible_child = check; var delete_button = new Gtk.Button.with_label (_("Delete Task")) { - halign = Gtk.Align.START, - css_classes = { Granite.STYLE_CLASS_DESTRUCTIVE_ACTION } + halign = Gtk.Align.START }; + delete_button.add_css_class (Granite.STYLE_CLASS_DESTRUCTIVE_ACTION); buttons_size_group.add_widget (delete_button); button_grid.attach (delete_button, 0, 0); From 202e248aadf8a34f91d67c1209f379d495757be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 12:12:13 -0700 Subject: [PATCH 63/86] Make buttonbox homogeneous --- src/Widgets/TaskRow.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 124538039b..97e0d9ac63 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -232,7 +232,8 @@ public class Tasks.Widgets.TaskRow : Gtk.ListBoxRow { buttons_size_group.add_widget (save_button); var right_buttons_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) { - halign = Gtk.Align.END + halign = Gtk.Align.END, + homogeneous = true }; right_buttons_box.append (cancel_button); right_buttons_box.append (save_button); From 71b010087566afe0cb344e6b3110b071c0e4ba84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 12:13:42 -0700 Subject: [PATCH 64/86] Granite.init --- data/{ButtonBox.css => Application.css} | 0 data/gresource.xml | 2 +- src/Application.vala | 6 ++---- 3 files changed, 3 insertions(+), 5 deletions(-) rename data/{ButtonBox.css => Application.css} (100%) diff --git a/data/ButtonBox.css b/data/Application.css similarity index 100% rename from data/ButtonBox.css rename to data/Application.css diff --git a/data/gresource.xml b/data/gresource.xml index 747b21849a..0cf52b2e53 100644 --- a/data/gresource.xml +++ b/data/gresource.xml @@ -2,7 +2,7 @@ LocationMarker.svg - ButtonBox.css + Application.css EditableLabel.css EntryPopover.css SourceRow.css diff --git a/src/Application.vala b/src/Application.vala index 4eea8158dc..883a6c4fd9 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -53,6 +53,8 @@ public class Tasks.Application : Gtk.Application { protected override void startup () { base.startup (); + Granite.init (); + unowned var granite_settings = Granite.Settings.get_default (); unowned var gtk_settings = Gtk.Settings.get_default (); @@ -62,10 +64,6 @@ public class Tasks.Application : Gtk.Application { gtk_settings.gtk_application_prefer_dark_theme = ((Granite.Settings) obj).prefers_color_scheme == DARK; }); - var button_box_style_provider = new Gtk.CssProvider (); - button_box_style_provider.load_from_resource ("io/elementary/tasks/ButtonBox.css"); - Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), button_box_style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - var quit_action = new SimpleAction ("quit", null); quit_action.activate.connect (() => { if (active_window != null) { From 40b88b49b35a21ca819d0192bf78906ab694bfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 12:16:06 -0700 Subject: [PATCH 65/86] Icons are added automatically --- data/gresource.xml | 2 +- src/MainWindow.vala | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/data/gresource.xml b/data/gresource.xml index 0cf52b2e53..a6805d92fd 100644 --- a/data/gresource.xml +++ b/data/gresource.xml @@ -9,6 +9,6 @@ TaskRow.css - LocationMarker.svg + LocationMarker.svg diff --git a/src/MainWindow.vala b/src/MainWindow.vala index b0f357d50d..7da5989bcb 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -33,7 +33,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { static construct { action_accelerators[ACTION_DELETE_SELECTED_LIST] = "BackSpace"; - Gtk.IconTheme.get_for_display (Gdk.Display.get_default ()).add_resource_path ("/io/elementary/tasks"); } construct { From a5825a9b2c7fd671ee0c1a8ff3c03a88d63e22a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 12:18:43 -0700 Subject: [PATCH 66/86] child, but alphabetize --- src/MainWindow.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 7da5989bcb..9374c6dfb9 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -60,10 +60,10 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { sidebar_header.pack_start (new Gtk.WindowControls (Gtk.PackType.START)); var scrolledwindow = new Gtk.ScrolledWindow () { + child = listbox, hexpand = true, vexpand = true, - hscrollbar_policy = Gtk.PolicyType.NEVER, - child = listbox + hscrollbar_policy = Gtk.PolicyType.NEVER }; add_tasklist_buttonbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); // TODO: check spacing From 35f85b3acd9d6db1861a043c943260b62490e192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 12:19:43 -0700 Subject: [PATCH 67/86] CSS for menu --- src/MainWindow.vala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 9374c6dfb9..95d9f8424b 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -71,10 +71,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var online_accounts_button = new Widgets.PopoverButton (); online_accounts_button.append (new Gtk.Label (_("Online Accounts Settings…"))); - var add_tasklist_box = new Gtk.Box (VERTICAL, 3) { - margin_top = 3, - margin_bottom = 3 - }; + var add_tasklist_box = new Gtk.Box (VERTICAL, 0); add_tasklist_box.append (add_tasklist_buttonbox); add_tasklist_box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); add_tasklist_box.append (online_accounts_button); @@ -82,6 +79,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { add_tasklist_popover = new Gtk.Popover () { child = add_tasklist_box }; + add_tasklist_popover.add_css_class (Granite.STYLE_CLASS_MENU); var add_tasklist_button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); add_tasklist_button_box.append (new Gtk.Image.from_icon_name ("list-add-symbolic")); From c0fba9928505be5a09a72050783935bac4894c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 12:25:56 -0700 Subject: [PATCH 68/86] Try to reduce diff --- meson.build | 2 +- src/MainWindow.vala | 34 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/meson.build b/meson.build index 6edf3c4afa..20ed4f8b08 100644 --- a/meson.build +++ b/meson.build @@ -35,7 +35,7 @@ tasks_deps = [ libecal_dep, dependency('libedataserver-1.2'), dependency('libgeoclue-2.0'), - # dependency('shumate-1.0'), + dependency('shumate-1.0'), dependency('libical-glib'), dependency('libportal'), dependency('libportal-gtk4') diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 95d9f8424b..cf4712e0f9 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -45,12 +45,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { ); } - listbox = new Gtk.ListBox (); - listbox.set_sort_func (sort_function); - - var scheduled_row = new Tasks.Widgets.ScheduledRow (); - listbox.append (scheduled_row); - var sidebar_header = new Gtk.HeaderBar () { title_widget = new Gtk.Label (null), show_title_buttons = false @@ -59,6 +53,20 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { sidebar_header.add_css_class (Granite.STYLE_CLASS_FLAT); sidebar_header.pack_start (new Gtk.WindowControls (Gtk.PackType.START)); + var main_header = new Gtk.HeaderBar () { + title_widget = new Gtk.Label (null), + show_title_buttons = false + }; + main_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); + main_header.add_css_class (Granite.STYLE_CLASS_FLAT); + main_header.pack_end (new Gtk.WindowControls (Gtk.PackType.END)); + + listbox = new Gtk.ListBox (); + listbox.set_sort_func (sort_function); + + var scheduled_row = new Tasks.Widgets.ScheduledRow (); + listbox.append (scheduled_row); + var scrolledwindow = new Gtk.ScrolledWindow () { child = listbox, hexpand = true, @@ -101,14 +109,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { sidebar.append (scrolledwindow); sidebar.append (actionbar); - var main_header = new Gtk.HeaderBar () { - title_widget = new Gtk.Label (null), - show_title_buttons = false - }; - main_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); - main_header.add_css_class (Granite.STYLE_CLASS_FLAT); - main_header.pack_end (new Gtk.WindowControls (Gtk.PackType.END)); - task_list_grid_stack = new Gtk.Stack (); var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); @@ -129,11 +129,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { // We need to hide the title area for the split headerbar titlebar = new Gtk.Grid () { visible = false }; - var settings = new GLib.Settings ("io.elementary.tasks"); - settings.bind ("window-width", this, "default-width", SettingsBindFlags.DEFAULT); - settings.bind ("window-height", this, "default-height", SettingsBindFlags.DEFAULT); - settings.bind ("window-maximized", this, "maximized", SettingsBindFlags.DEFAULT); - close_request.connect (() => { ((Application)application).request_background.begin (() => destroy ()); @@ -361,7 +356,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { } var header_label = new Granite.HeaderLabel (Util.get_esource_collection_display_name (row.source)) { - // ellipsize = Pango.EllipsizeMode.MIDDLE, margin_start = 6 }; From bd825766706d2af4d350537fc43d9c5cf0f700cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 12:29:10 -0700 Subject: [PATCH 69/86] Revert network monitor stuff --- src/TaskModel.vala | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/TaskModel.vala b/src/TaskModel.vala index 388b94eda5..0c62cdb38d 100644 --- a/src/TaskModel.vala +++ b/src/TaskModel.vala @@ -36,7 +36,7 @@ public class Tasks.TaskModel : Object { public delegate void TasksRemovedFunc (SList cids); private Gee.Future registry; - // private NetworkMonitor network_monitor; + private NetworkMonitor network_monitor; private HashTable task_list_client; private HashTable> task_list_client_views; @@ -133,15 +133,14 @@ public class Tasks.TaskModel : Object { construct { task_list_client = new HashTable (str_hash, str_equal); task_list_client_views = new HashTable> (direct_hash, direct_equal); // vala-lint=line-length - // Failed to initialize portal (GNetworkMonitorPortal) for gio-network-monitor: Not using portals - // network_monitor = NetworkMonitor.get_default (); + network_monitor = NetworkMonitor.get_default (); } public async void start () { var promise = new Gee.Promise (); registry = promise.future; yield init_registry (promise); - // network_monitor.network_changed.connect (network_changed); + network_monitor.network_changed.connect (network_changed); } private async void init_registry (Gee.Promise promise) { @@ -240,8 +239,7 @@ public class Tasks.TaskModel : Object { } private async bool refresh_collection (E.Source collection_source, Cancellable? cancellable = null) throws Error { - // if (network_monitor.network_available && registry.ready) { - if (registry.ready) { + if (network_monitor.network_available && registry.ready) { debug ("Scheduling collection refresh '%s'…", collection_source.dup_display_name ()); return yield registry.value.refresh_backend (collection_source.dup_uid (), cancellable); } @@ -250,8 +248,7 @@ public class Tasks.TaskModel : Object { } public async bool refresh_task_list (E.Source task_list, Cancellable? cancellable = null) throws Error { - // if (network_monitor.network_available && task_list_client.contains (task_list.dup_uid ())) { - if (task_list_client.contains (task_list.dup_uid ())) { + if (network_monitor.network_available && task_list_client.contains (task_list.dup_uid ())) { var client = task_list_client.get (task_list.dup_uid ()); if (client.check_refresh_supported ()) { From f4a88b859d7e1e8a0bd3ddc83a4ad5da7ad6f6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 15 May 2024 13:12:20 -0700 Subject: [PATCH 70/86] Remove disable deprecated thing --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 20ed4f8b08..ea235673fc 100644 --- a/meson.build +++ b/meson.build @@ -9,7 +9,7 @@ i18n = import('i18n') add_project_arguments('-DGETTEXT_PACKAGE="@0@"'.format (meson.project_name()), language:'c') add_project_arguments('-DLIBICAL_GLIB_UNSTABLE_API=1', language: 'c') -add_project_arguments('-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED', language: 'c') + gresource = gnome.compile_resources( 'gresource', join_paths('data', 'gresource.xml'), From 020408064ed459c8f62f585bd22c753faedd4e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 16 May 2024 11:05:58 -0700 Subject: [PATCH 71/86] code style --- src/MainWindow.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 582826b483..ef32a2fb38 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -81,7 +81,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { var add_tasklist_box = new Gtk.Box (VERTICAL, 0); add_tasklist_box.append (add_tasklist_buttonbox); - add_tasklist_box.append (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); + add_tasklist_box.append (new Gtk.Separator (HORIZONTAL)); add_tasklist_box.append (online_accounts_button); add_tasklist_popover = new Gtk.Popover () { @@ -120,7 +120,7 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { main_box.append (main_header); main_box.append (task_list_grid_stack); - var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL) { + var paned = new Gtk.Paned (HORIZONTAL) { start_child = sidebar, end_child = main_box, resize_start_child = false, From 854caecf17139233eea0cbed50914469f2b7ea49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 16 May 2024 11:33:03 -0700 Subject: [PATCH 72/86] Use has_frame property --- src/Widgets/EditableLabel.vala | 4 +--- src/Widgets/EntryPopover/Generic.vala | 3 +-- src/Widgets/TaskListGrid.vala | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index 73ae7f862c..8e0fc4b86a 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -45,11 +45,9 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { xalign = 0 }; - var edit_button = new Gtk.Button () { - icon_name = "edit-symbolic", + var edit_button = new Gtk.Button.from_icon_name ("edit-symbolic") { tooltip_text = _("Edit…") }; - edit_button.add_css_class (Granite.STYLE_CLASS_FLAT); var button_revealer = new Gtk.Revealer () { valign = Gtk.Align.CENTER, diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index e2f3fc78d7..03cf25ce9f 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -42,15 +42,14 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { popover_button_box.append (label); popover_button = new Gtk.MenuButton () { + has_frame = false, popover = popover, child = popover_button_box }; - popover_button.add_css_class (Granite.STYLE_CLASS_FLAT); var delete_button = new Gtk.Button.from_icon_name ("process-stop-symbolic") { tooltip_text = _("Remove") }; - delete_button.add_css_class (Granite.STYLE_CLASS_FLAT); delete_button.add_css_class ("delete-button"); var delete_button_revealer = new Gtk.Revealer () { diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index de250e4a87..8becac4815 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -43,7 +43,6 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { icon_name = "view-more-symbolic", tooltip_text = _("Edit Name and Appearance") }; - settings_button.add_css_class (Granite.STYLE_CLASS_FLAT); settings_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); add_task_list = new Gtk.ListBox () { From 957664affac08e1d70dcbb64e64dd6618a863964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 16 May 2024 12:10:47 -0700 Subject: [PATCH 73/86] Revert "Revert network monitor stuff" This reverts commit bd825766706d2af4d350537fc43d9c5cf0f700cf. --- src/TaskModel.vala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/TaskModel.vala b/src/TaskModel.vala index 0c62cdb38d..388b94eda5 100644 --- a/src/TaskModel.vala +++ b/src/TaskModel.vala @@ -36,7 +36,7 @@ public class Tasks.TaskModel : Object { public delegate void TasksRemovedFunc (SList cids); private Gee.Future registry; - private NetworkMonitor network_monitor; + // private NetworkMonitor network_monitor; private HashTable task_list_client; private HashTable> task_list_client_views; @@ -133,14 +133,15 @@ public class Tasks.TaskModel : Object { construct { task_list_client = new HashTable (str_hash, str_equal); task_list_client_views = new HashTable> (direct_hash, direct_equal); // vala-lint=line-length - network_monitor = NetworkMonitor.get_default (); + // Failed to initialize portal (GNetworkMonitorPortal) for gio-network-monitor: Not using portals + // network_monitor = NetworkMonitor.get_default (); } public async void start () { var promise = new Gee.Promise (); registry = promise.future; yield init_registry (promise); - network_monitor.network_changed.connect (network_changed); + // network_monitor.network_changed.connect (network_changed); } private async void init_registry (Gee.Promise promise) { @@ -239,7 +240,8 @@ public class Tasks.TaskModel : Object { } private async bool refresh_collection (E.Source collection_source, Cancellable? cancellable = null) throws Error { - if (network_monitor.network_available && registry.ready) { + // if (network_monitor.network_available && registry.ready) { + if (registry.ready) { debug ("Scheduling collection refresh '%s'…", collection_source.dup_display_name ()); return yield registry.value.refresh_backend (collection_source.dup_uid (), cancellable); } @@ -248,7 +250,8 @@ public class Tasks.TaskModel : Object { } public async bool refresh_task_list (E.Source task_list, Cancellable? cancellable = null) throws Error { - if (network_monitor.network_available && task_list_client.contains (task_list.dup_uid ())) { + // if (network_monitor.network_available && task_list_client.contains (task_list.dup_uid ())) { + if (task_list_client.contains (task_list.dup_uid ())) { var client = task_list_client.get (task_list.dup_uid ()); if (client.check_refresh_supported ()) { From dfa5d7f41dd579dc670ab0c635c68ddfaab43417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 16 May 2024 12:23:37 -0700 Subject: [PATCH 74/86] TaskListGrid: use toolbarview (#384) --- meson.build | 1 + src/MainWindow.vala | 15 +------------ src/Widgets/TaskListGrid.vala | 40 +++++++++++++++++++++++------------ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/meson.build b/meson.build index ea235673fc..483c61a3cd 100644 --- a/meson.build +++ b/meson.build @@ -33,6 +33,7 @@ tasks_deps = [ dependency('granite-7', version: '>=7.0.0'), dependency('gtk4'), libecal_dep, + dependency('libadwaita-1'), dependency('libedataserver-1.2'), dependency('libgeoclue-2.0'), dependency('shumate-1.0'), diff --git a/src/MainWindow.vala b/src/MainWindow.vala index ef32a2fb38..8aa6dfc6ae 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -53,14 +53,6 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { sidebar_header.add_css_class (Granite.STYLE_CLASS_FLAT); sidebar_header.pack_start (new Gtk.WindowControls (Gtk.PackType.START)); - var main_header = new Gtk.HeaderBar () { - title_widget = new Gtk.Label (null), - show_title_buttons = false - }; - main_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); - main_header.add_css_class (Granite.STYLE_CLASS_FLAT); - main_header.pack_end (new Gtk.WindowControls (Gtk.PackType.END)); - listbox = new Gtk.ListBox (); listbox.set_sort_func (sort_function); @@ -115,14 +107,9 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { task_list_grid_stack = new Gtk.Stack (); - var main_box = new Gtk.Box (VERTICAL, 0); - main_box.add_css_class (Granite.STYLE_CLASS_BACKGROUND); - main_box.append (main_header); - main_box.append (task_list_grid_stack); - var paned = new Gtk.Paned (HORIZONTAL) { start_child = sidebar, - end_child = main_box, + end_child = task_list_grid_stack, resize_start_child = false, shrink_end_child = false, shrink_start_child = false diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 8becac4815..a55d591942 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -26,10 +26,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { warning ("unable to get the registry, assuming task list is not from gtasks"); } - editable_title = new EditableLabel () { - margin_start = 24, - hexpand = true - }; + editable_title = new EditableLabel (); editable_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); editable_title.add_css_class (Granite.STYLE_CLASS_ACCENT); @@ -37,13 +34,25 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var settings_button = new Gtk.MenuButton () { popover = list_settings_popover, - margin_end = 24, - valign = Gtk.Align.CENTER, - hexpand = false, + valign = START, + halign = END, + hexpand = true, icon_name = "view-more-symbolic", tooltip_text = _("Edit Name and Appearance") }; - settings_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + + var window_controls = new Gtk.WindowControls (END) { + valign = START + }; + + var header_box = new Gtk.Box (HORIZONTAL, 0) { + margin_top = 6, + margin_end = 6, + margin_start = 24 + }; + header_box.append (editable_title); + header_box.append (settings_button); + header_box.append (window_controls); add_task_list = new Gtk.ListBox () { margin_top = 24, @@ -95,11 +104,16 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { child = task_list }; - column_spacing = 12; - attach (editable_title, 0, 0); - attach (settings_button, 1, 0); - attach (add_task_list, 0, 1, 2); - attach (scrolled_window, 0, 2, 2); + var main_box = new Gtk.Box (VERTICAL, 12); + main_box.append (add_task_list); + main_box.append (scrolled_window); + + var toolbar_view = new Adw.ToolbarView () { + content = main_box + }; + toolbar_view.add_top_bar (header_box); + + attach (toolbar_view, 0, 0); Application.settings.changed["show-completed"].connect (() => { on_show_completed_changed (Application.settings.get_boolean ("show-completed")); From fa1b06f9caeb69fa2cba1dc456b5c26619ca5784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 16 May 2024 12:24:31 -0700 Subject: [PATCH 75/86] provider from string --- src/Application.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 0fca35f2e2..9a561683c4 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -157,7 +157,7 @@ public class Tasks.Application : Gtk.Application { """.printf (color, color); var style_provider = new Gtk.CssProvider (); - style_provider.load_from_data ((uint8[])style); + style_provider.load_from_string (style); providers[color] = style_provider; } From 79f6a5f9aa0753dab46bf334d0881dd02b830220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 16 May 2024 12:25:56 -0700 Subject: [PATCH 76/86] Revert "TaskListGrid: use toolbarview (#384)" This reverts commit dfa5d7f41dd579dc670ab0c635c68ddfaab43417. --- meson.build | 1 - src/MainWindow.vala | 15 ++++++++++++- src/Widgets/TaskListGrid.vala | 40 ++++++++++++----------------------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/meson.build b/meson.build index 483c61a3cd..ea235673fc 100644 --- a/meson.build +++ b/meson.build @@ -33,7 +33,6 @@ tasks_deps = [ dependency('granite-7', version: '>=7.0.0'), dependency('gtk4'), libecal_dep, - dependency('libadwaita-1'), dependency('libedataserver-1.2'), dependency('libgeoclue-2.0'), dependency('shumate-1.0'), diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 8aa6dfc6ae..ef32a2fb38 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -53,6 +53,14 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { sidebar_header.add_css_class (Granite.STYLE_CLASS_FLAT); sidebar_header.pack_start (new Gtk.WindowControls (Gtk.PackType.START)); + var main_header = new Gtk.HeaderBar () { + title_widget = new Gtk.Label (null), + show_title_buttons = false + }; + main_header.add_css_class (Granite.STYLE_CLASS_DEFAULT_DECORATION); + main_header.add_css_class (Granite.STYLE_CLASS_FLAT); + main_header.pack_end (new Gtk.WindowControls (Gtk.PackType.END)); + listbox = new Gtk.ListBox (); listbox.set_sort_func (sort_function); @@ -107,9 +115,14 @@ public class Tasks.MainWindow : Gtk.ApplicationWindow { task_list_grid_stack = new Gtk.Stack (); + var main_box = new Gtk.Box (VERTICAL, 0); + main_box.add_css_class (Granite.STYLE_CLASS_BACKGROUND); + main_box.append (main_header); + main_box.append (task_list_grid_stack); + var paned = new Gtk.Paned (HORIZONTAL) { start_child = sidebar, - end_child = task_list_grid_stack, + end_child = main_box, resize_start_child = false, shrink_end_child = false, shrink_start_child = false diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index a55d591942..8becac4815 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -26,7 +26,10 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { warning ("unable to get the registry, assuming task list is not from gtasks"); } - editable_title = new EditableLabel (); + editable_title = new EditableLabel () { + margin_start = 24, + hexpand = true + }; editable_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); editable_title.add_css_class (Granite.STYLE_CLASS_ACCENT); @@ -34,25 +37,13 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var settings_button = new Gtk.MenuButton () { popover = list_settings_popover, - valign = START, - halign = END, - hexpand = true, + margin_end = 24, + valign = Gtk.Align.CENTER, + hexpand = false, icon_name = "view-more-symbolic", tooltip_text = _("Edit Name and Appearance") }; - - var window_controls = new Gtk.WindowControls (END) { - valign = START - }; - - var header_box = new Gtk.Box (HORIZONTAL, 0) { - margin_top = 6, - margin_end = 6, - margin_start = 24 - }; - header_box.append (editable_title); - header_box.append (settings_button); - header_box.append (window_controls); + settings_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); add_task_list = new Gtk.ListBox () { margin_top = 24, @@ -104,16 +95,11 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { child = task_list }; - var main_box = new Gtk.Box (VERTICAL, 12); - main_box.append (add_task_list); - main_box.append (scrolled_window); - - var toolbar_view = new Adw.ToolbarView () { - content = main_box - }; - toolbar_view.add_top_bar (header_box); - - attach (toolbar_view, 0, 0); + column_spacing = 12; + attach (editable_title, 0, 0); + attach (settings_button, 1, 0); + attach (add_task_list, 0, 1, 2); + attach (scrolled_window, 0, 2, 2); Application.settings.changed["show-completed"].connect (() => { on_show_completed_changed (Application.settings.get_boolean ("show-completed")); From ac91fbbfb4fa864de1f561225c468f770eec5903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 20 May 2024 18:05:06 -0700 Subject: [PATCH 77/86] Reduce diff --- src/Widgets/TaskListGrid.vala | 41 +++++++++++------------------------ 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 8becac4815..16283705d6 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -27,8 +27,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } editable_title = new EditableLabel () { - margin_start = 24, - hexpand = true + margin_start = 24 }; editable_title.add_css_class (Granite.STYLE_CLASS_H1_LABEL); editable_title.add_css_class (Granite.STYLE_CLASS_ACCENT); @@ -36,18 +35,18 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { var list_settings_popover = new Tasks.Widgets.ListSettingsPopover (source); var settings_button = new Gtk.MenuButton () { - popover = list_settings_popover, - margin_end = 24, - valign = Gtk.Align.CENTER, - hexpand = false, + halign = END, icon_name = "view-more-symbolic", - tooltip_text = _("Edit Name and Appearance") + margin_end = 24, + popover = list_settings_popover, + tooltip_text = _("Edit Name and Appearance"), + valign = CENTER }; settings_button.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); add_task_list = new Gtk.ListBox () { margin_top = 24, - selection_mode = Gtk.SelectionMode.SINGLE, + selection_mode = SINGLE, activate_on_single_click = true }; add_task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); @@ -81,12 +80,12 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); task_list = new Gtk.ListBox () { - selection_mode = Gtk.SelectionMode.SINGLE, + selection_mode = MULTIPLE, activate_on_single_click = true }; - task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); - task_list.set_sort_func (sort_function); task_list.set_placeholder (placeholder); + task_list.set_sort_func (sort_function); + task_list.add_css_class (Granite.STYLE_CLASS_BACKGROUND); var scrolled_window = new Gtk.ScrolledWindow () { hexpand = true, @@ -109,10 +108,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { settings_button.activate.connect (() => { unowned var main_window = (MainWindow) get_root (); - // TODO: - // error: `Gtk.MenuButton.get_active' is not available in gtk4 4.6.6. Use gtk4 >= 4.10 - // if (settings_button.active) { - if (false) { + if (settings_button.active) { list_settings_popover.source = source; if (main_window != null) { @@ -179,19 +175,8 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } private void set_view_for_query (string query) { - Gtk.Widget[] children_for_removal = {}; - unowned var child = task_list.get_first_child (); - while (child != null) { - if (child != placeholder) { - children_for_removal += child; - } - - child = child.get_next_sibling (); - } - - for (int i = 0; i < children_for_removal.length; i++) { - task_list.remove (children_for_removal[i]); - children_for_removal[i].destroy (); + while (task_list.get_row_at_index (0) != null) { + task_list.remove (task_list.get_row_at_index (0)); } if (view != null) { From 143b97dc362e01b2f0de4283c496d6f26a3d7499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 20 May 2024 18:27:15 -0700 Subject: [PATCH 78/86] Use function for remove_all --- meson.build | 2 +- src/Widgets/TaskListGrid.vala | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index ea235673fc..763b4718a2 100644 --- a/meson.build +++ b/meson.build @@ -31,7 +31,7 @@ tasks_deps = [ dependency('glib-2.0'), dependency('gobject-2.0'), dependency('granite-7', version: '>=7.0.0'), - dependency('gtk4'), + dependency('gtk4', version: '>=4.12'), libecal_dep, dependency('libedataserver-1.2'), dependency('libgeoclue-2.0'), diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index 16283705d6..56217399d8 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -175,9 +175,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { } private void set_view_for_query (string query) { - while (task_list.get_row_at_index (0) != null) { - task_list.remove (task_list.get_row_at_index (0)); - } + task_list.remove_all (); if (view != null) { Application.model.destroy_task_list_view (view); From 185c0535cfbb48bdee78cf0f683dae9d74515406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 29 May 2024 19:15:38 -0700 Subject: [PATCH 79/86] Remove duplicate placeholder --- src/Widgets/TaskListGrid.vala | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index a0dac6a169..d5f6819b12 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -81,11 +81,6 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { placeholder.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); - var placeholder = new Gtk.Label (_("No Tasks")); - placeholder.show (); - placeholder.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); - placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); - task_list = new Gtk.ListBox () { selection_mode = MULTIPLE, activate_on_single_click = true From e6ee17a38fabb04c6fedbc61d840906a30d1b408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 29 May 2024 19:17:11 -0700 Subject: [PATCH 80/86] don't need to cache placeholder --- src/Widgets/TaskListGrid.vala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Widgets/TaskListGrid.vala b/src/Widgets/TaskListGrid.vala index d5f6819b12..522d7a6ac1 100644 --- a/src/Widgets/TaskListGrid.vala +++ b/src/Widgets/TaskListGrid.vala @@ -9,7 +9,6 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { private EditableLabel editable_title; private Gtk.ListBox add_task_list; - private Gtk.Label placeholder; private Gtk.ListBox task_list; private bool is_gtasks; @@ -77,7 +76,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { }); add_task_list.append (add_task_row); - placeholder = new Gtk.Label (_("No Tasks")); + var placeholder = new Gtk.Label (_("No Tasks")); placeholder.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); placeholder.add_css_class (Granite.STYLE_CLASS_H2_LABEL); @@ -93,7 +92,7 @@ public class Tasks.Widgets.TaskListGrid : Gtk.Grid { child = task_list, hexpand = true, vexpand = true, - hscrollbar_policy = Gtk.PolicyType.NEVER, + hscrollbar_policy = Gtk.PolicyType.NEVER }; column_spacing = 12; From 48d3173e6bd41f408817f6716382f43762dfa28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 5 Jun 2024 13:28:22 -0700 Subject: [PATCH 81/86] remove extra comma --- src/Widgets/EditableLabel.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/EditableLabel.vala b/src/Widgets/EditableLabel.vala index 9bccf51f3e..2af96b8578 100644 --- a/src/Widgets/EditableLabel.vala +++ b/src/Widgets/EditableLabel.vala @@ -45,7 +45,7 @@ public class Tasks.Widgets.EditableLabel : Gtk.Widget { }; entry = new Gtk.Entry () { - hexpand = true, + hexpand = true }; stack = new Gtk.Stack () { From 9ea03a6357b2380c9970cf3533da1c84319a47c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Jun 2024 15:46:42 -0700 Subject: [PATCH 82/86] Remove duplicate code from bad merge --- src/Widgets/EntryPopover/Generic.vala | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 46c57b0596..17f6f98134 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -122,28 +122,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { return GLib.Source.REMOVE; }); }); - - delete_button.clicked.connect (() => { - var value_has_changed = value != null; - value = null; - if (value_has_changed) { - value_changed (value); - } - }); - - notify["value"].connect (() => { - var value_formatted = value_format (value); - if (value_formatted == null) { - label.label = placeholder; - - if (delete_button_revealer.reveal_child) { - delete_button_revealer.reveal_child = false; - } - - } else { - label.label = value_formatted; - } - }); } ~Generic () { From 5fb451343a9ae27bb0c86b259f6f3d77af45fcc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Jun 2024 16:02:26 -0700 Subject: [PATCH 83/86] Simplify CSS --- data/Application.css | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/data/Application.css b/data/Application.css index bdfc249105..61f2b8bb5f 100644 --- a/data/Application.css +++ b/data/Application.css @@ -15,39 +15,23 @@ editable-label entry text { padding: 0; } -editable-label button { - padding: 0.4rem; -} - entry-popover .container { border-radius: 3px; background: @SILVER_300; + color: @SILVER_900; } -entry-popover menubutton button.toggle { +entry-popover .container button { background: transparent; border: none; - color: @SILVER_900; + color: inherit; font-size: 0.9em; box-shadow: none; font-weight: 600; } -entry-popover .delete-button { - padding: 0.4rem; - color: @SILVER_900; -} - - entry-popover.error .container { background: alpha(@error_color, 0.2); -} - -entry-popover.error menubutton button.toggle { - color: @error_color; -} - -entry-popover.error .delete-button { color: @error_color; } From 34d7efe7bc89ff721728add41ff78d0225d9c0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Jun 2024 16:04:17 -0700 Subject: [PATCH 84/86] Simplify more --- data/Application.css | 6 +++--- src/Widgets/EntryPopover/Generic.vala | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/data/Application.css b/data/Application.css index 61f2b8bb5f..6efb977216 100644 --- a/data/Application.css +++ b/data/Application.css @@ -15,13 +15,13 @@ editable-label entry text { padding: 0; } -entry-popover .container { +entry-popover > box { border-radius: 3px; background: @SILVER_300; color: @SILVER_900; } -entry-popover .container button { +entry-popover > box button { background: transparent; border: none; color: inherit; @@ -30,7 +30,7 @@ entry-popover .container button { font-weight: 600; } -entry-popover.error .container { +entry-popover.error > box { background: alpha(@error_color, 0.2); color: @error_color; } diff --git a/src/Widgets/EntryPopover/Generic.vala b/src/Widgets/EntryPopover/Generic.vala index 17f6f98134..7ba4097a48 100644 --- a/src/Widgets/EntryPopover/Generic.vala +++ b/src/Widgets/EntryPopover/Generic.vala @@ -59,7 +59,6 @@ public abstract class Tasks.Widgets.EntryPopover.Generic : Gtk.Widget { }; var button_box = new Gtk.Box (HORIZONTAL, 0); - button_box.add_css_class ("container"); button_box.append (popover_button); button_box.append (delete_button_revealer); button_box.set_parent (this); From 1608678913e0d6072ed6babb513c63de270f1945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 10 Jun 2024 16:05:28 -0700 Subject: [PATCH 85/86] CSS: even simpler --- data/Application.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/data/Application.css b/data/Application.css index 6efb977216..ed829042ab 100644 --- a/data/Application.css +++ b/data/Application.css @@ -22,11 +22,8 @@ entry-popover > box { } entry-popover > box button { - background: transparent; - border: none; color: inherit; font-size: 0.9em; - box-shadow: none; font-weight: 600; } From e8ae3c7ce7265a99e22fc4e2110de32ead58ff96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 11 Jul 2024 11:02:47 -0700 Subject: [PATCH 86/86] Update flatpak manifest --- io.elementary.tasks.json | 102 ++++++++------------------------------- 1 file changed, 21 insertions(+), 81 deletions(-) diff --git a/io.elementary.tasks.json b/io.elementary.tasks.json index 150be8651a..e48670f0b2 100644 --- a/io.elementary.tasks.json +++ b/io.elementary.tasks.json @@ -96,87 +96,6 @@ } ] }, - { - "name": "clutter-gtk", - "cleanup": [ - "/share/gtk-doc" - ], - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/clutter-gtk/1.8/clutter-gtk-1.8.4.tar.xz", - "sha256": "521493ec038973c77edcb8bc5eac23eed41645117894aaee7300b2487cb42b06" - } - ], - "modules": [ - { - "name": "cogl", - "config-opts": [ - "--disable-cogl-gst", - "--disable-gtk-doc", - "--enable-xlib-egl-platform", - "--enable-wayland-egl-platform" - ], - "cleanup": [ - "/share/gtk-doc", - "/share/cogl/examples-data" - ], - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/cogl/1.22/cogl-1.22.8.tar.xz", - "sha256": "a805b2b019184710ff53d0496f9f0ce6dcca420c141a0f4f6fcc02131581d759" - } - ] - }, - { - "name": "clutter", - "config-opts": [ - "--disable-gtk-doc", - "--enable-egl-backend", - "--enable-wayland-backend", - "--enable-deprecated=no" - ], - "cleanup": [ - "/share/gtk-doc" - ], - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/clutter/1.26/clutter-1.26.4.tar.xz", - "sha256": "8b48fac159843f556d0a6be3dbfc6b083fc6d9c58a20a49a6b4919ab4263c4e6" - } - ] - }, - { - "name": "clutter-gst", - "config-opts": [ - "--disable-gtk-doc" - ], - "cleanup": [ - "/share/gtk-doc" - ], - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/clutter-gst/3.0/clutter-gst-3.0.27.tar.xz", - "sha256": "fe69bd6c659d24ab30da3f091eb91cd1970026d431179b0724f13791e8ad9f9d" - } - ] - } - ] - }, - { - "name": "champlain", - "buildsystem": "meson", - "sources": [ - { - "type": "archive", - "url": "https://download.gnome.org/sources/libchamplain/0.12/libchamplain-0.12.21.tar.xz", - "sha256": "a915cd172a0c52944c5579fcb4683f8a878c571bf5e928254b5dafefc727e5a7" - } - ] - }, { "name": "geocode-glib", "buildsystem": "meson", @@ -208,6 +127,27 @@ } ] }, + { + "name": "libshumate", + "buildsystem": "meson", + "config-opts": [ + "-Ddemos=false", + "-Dgtk_doc=false", + "-Dvapi=false" + ], + "sources": [ + { + "type": "archive", + "url": "https://download.gnome.org/sources/libshumate/1.2/libshumate-1.2.1.tar.xz", + "sha256": "1105ee077e2147f2a039cddfa616fa5cb9438883dd940427e11699dcd6549c11", + "x-checker-data": { + "type": "gnome", + "stable-only": false, + "name": "libshumate" + } + } + ] + }, { "name": "tasks", "buildsystem": "meson",