Skip to content

Commit

Permalink
feat: use NavigationView
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Jul 30, 2024
1 parent 0ec09c8 commit 283c066
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 289 deletions.
2 changes: 1 addition & 1 deletion data/io.github.alainm23.planify.appdata.xml.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<release version="4.9.0" date="2024-07-11">
<description translate="no">
<ul>
<li>Added feature to switch between task and note..</li>
<li>Added feature to switch between task and note.</li>
<li>Added a task change history feature.</li>
<li>Fixed bug when importing backup and not recovering labels.</li>
<li>Hindi translation update thanks to @Scrambled777.</li>
Expand Down
9 changes: 9 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ subdir('data')
# subdir('search-provider')
subdir('po')

executable(
application_id,
sources,
asresources,
config_file,
dependencies: deps,
install: true
)

summary({
'Tracing': get_option('tracing'),
'Profile': get_option('profile'),
Expand Down
97 changes: 2 additions & 95 deletions src/Layouts/SectionRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
private Gtk.Revealer bottom_revealer;
private Widgets.EditableLabel name_editable;
private Gtk.ListBox listbox;
private Gtk.ListBox checked_listbox;
private Gtk.Revealer checked_revealer;
private Gtk.Revealer content_revealer;
private Gtk.Grid drop_widget;
private Gtk.Revealer drop_revealer;
Expand All @@ -46,8 +44,7 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {

public bool has_children {
get {
return items.size > 0 ||
items_checked.size > 0;
return items.size > 0;
}
}

Expand All @@ -64,7 +61,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
}

public Gee.HashMap <string, Layouts.ItemRow> items;
public Gee.HashMap <string, Layouts.ItemRow> items_checked;

public signal void children_size_changed ();

Expand Down Expand Up @@ -93,7 +89,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
add_css_class ("row");

items = new Gee.HashMap <string, Layouts.ItemRow> ();
items_checked = new Gee.HashMap <string, Layouts.ItemRow> ();

name_editable = new Widgets.EditableLabel (("New Section"), false) {
valign = Gtk.Align.CENTER,
Expand Down Expand Up @@ -190,31 +185,12 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
css_classes = { "listbox-background" }
};

checked_listbox = new Gtk.ListBox () {
valign = Gtk.Align.START,
hexpand = true,
css_classes = { "listbox-background" }
};

checked_listbox.set_sort_func (set_checked_sort_func);

var checked_listbox_grid = new Gtk.Grid ();
checked_listbox_grid.attach (checked_listbox, 0, 0);

checked_revealer = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN,
reveal_child = true
};

checked_revealer.child = checked_listbox_grid;

var bottom_grid = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
hexpand = true,
margin_end = 12
};

bottom_grid.append (listbox);
bottom_grid.append (checked_revealer);

bottom_revealer = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN,
Expand All @@ -239,7 +215,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
child = content_revealer;

add_items ();
show_completed_changed ();
build_drag_and_drop ();

Timeout.add (content_revealer.transition_duration, () => {
Expand Down Expand Up @@ -278,32 +253,18 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
});

Services.EventBus.get_default ().checked_toggled.connect ((item, old_checked) => {
if (item.project_id == section.project_id && item.section_id == section.id && !item.has_parent) {
print ("Content: %s - %s\n".printf (item.content, old_checked.to_string ()));

if (item.project_id == section.project_id && item.section_id == section.id && !item.has_parent) {
if (!old_checked) {
if (items.has_key (item.id)) {
items [item.id].hide_destroy ();
items.unset (item.id);
}

if (!items_checked.has_key (item.id)) {
items_checked [item.id] = new Layouts.ItemRow (item, true);
checked_listbox.insert (items_checked [item.id], 0);
}
} else {
if (items_checked.has_key (item.id)) {
items_checked [item.id].hide_destroy ();
items_checked.unset (item.id);
}

if (!items.has_key (item.id)) {
items [item.id] = new Layouts.ItemRow (item, true);
listbox.append (items [item.id]);
}
}

checked_listbox.invalidate_sort ();
}
});

Expand All @@ -315,10 +276,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
}
}

if (items_checked.has_key (item.id)) {
items_checked [item.id].update_request ();
}

listbox.invalidate_filter ();
});

Expand All @@ -327,11 +284,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
items [item.id].hide_destroy ();
items.unset (item.id);
}

if (items_checked.has_key (item.id)) {
items_checked [item.id].hide_destroy ();
items_checked.unset (item.id);
}
});

Services.EventBus.get_default ().item_moved.connect ((item, old_project_id, old_section_id, old_parent_id) => {
Expand All @@ -341,11 +293,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
items [item.id].hide_destroy ();
items.unset (item.id);
}

if (items_checked.has_key (item.id)) {
items_checked [item.id].hide_destroy ();
items_checked.unset (item.id);
}
}

// vala-lint=no-space
Expand Down Expand Up @@ -385,8 +332,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
}
});

section.project.show_completed_changed.connect (show_completed_changed);

section.project.sort_order_changed.connect (() => {
update_sort ();
});
Expand Down Expand Up @@ -492,43 +437,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
});
}

private void show_completed_changed () {
if (section.project.show_completed) {
add_completed_items ();
} else {
foreach (Layouts.ItemRow row in items_checked.values) {
row.hide_destroy ();
}

items_checked.clear ();
}

checked_revealer.reveal_child = section.project.show_completed;
}

public void add_completed_items () {
foreach (Layouts.ItemRow row in items_checked.values) {
row.hide_destroy ();
}

items_checked.clear ();

foreach (Objects.Item item in is_inbox_section ? section.project.items : section.items) {
add_complete_item (item);
}

checked_listbox.invalidate_sort ();
}

public void add_complete_item (Objects.Item item) {
if (section.project.show_completed && item.checked) {
if (!items_checked.has_key (item.id)) {
items_checked [item.id] = new Layouts.ItemRow (item, true);
checked_listbox.append (items_checked [item.id]);
}
}
}

private void update_sort () {
if (section.project.sort_order == 0) {
listbox.set_sort_func (null);
Expand All @@ -537,7 +445,6 @@ public class Layouts.SectionRow : Gtk.ListBoxRow {
}

listbox.invalidate_filter ();
checked_listbox.invalidate_sort ();
}

public void add_items () {
Expand Down
Loading

0 comments on commit 283c066

Please sign in to comment.