Skip to content

Commit

Permalink
feat: update menuitem
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Sep 19, 2024
1 parent 6e73662 commit 2d7d11d
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 117 deletions.
7 changes: 6 additions & 1 deletion core/Widgets/ContextMenu/MenuItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class Widgets.ContextMenu.MenuItem : Gtk.Button {
);
}

construct {
construct {
add_css_class ("flat");
add_css_class ("no-font-bold");

Expand Down Expand Up @@ -177,6 +177,11 @@ public class Widgets.ContextMenu.MenuItem : Gtk.Button {

clicked.connect (() => {
activate_item ();

var popover = (Gtk.Popover) get_ancestor (typeof (Gtk.Popover));
if (popover != null) {
popover.popdown ();
}
});
}
}
2 changes: 0 additions & 2 deletions src/Dialogs/CompletedTasks.vala
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,6 @@ public class Dialogs.CompletedTasks : Adw.Dialog {
};

section_item.notify["selected"].connect (() => {
popover.popdown ();

Objects.Section section = project.sections[section_item.selected];
add_update_filter (section);
});
Expand Down
2 changes: 0 additions & 2 deletions src/Dialogs/Preferences/PreferencesWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -950,12 +950,10 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesDialog {
});

todoist_item.clicked.connect (() => {
popover.popdown ();
push_subpage (get_oauth_todoist_page ());
});

caldav_item.clicked.connect (() => {
popover.popdown ();
push_subpage (get_caldav_setup_page ());
});

Expand Down
12 changes: 0 additions & 12 deletions src/Layouts/ItemBoard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,6 @@ public class Layouts.ItemBoard : Layouts.ItemBase {
menu_handle_popover.popup ();

move_item.activate_item.connect (() => {
menu_handle_popover.popdown ();

Dialogs.ProjectPicker.ProjectPicker dialog;
if (item.project.is_inbox_project) {
dialog = new Dialogs.ProjectPicker.ProjectPicker.for_projects ();
Expand All @@ -710,51 +708,41 @@ public class Layouts.ItemBoard : Layouts.ItemBase {
});

today_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
update_date (Utils.Datetime.get_date_only (new DateTime.now_local ()));
});

tomorrow_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
update_date (Utils.Datetime.get_date_only (new DateTime.now_local ().add_days (1)));
});

pinboard_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
item.update_pin (!item.pinned);
});

no_date_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
update_date (null);
});

complete_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
checked_button.active = !checked_button.active;
checked_toggled (checked_button.active);
});

edit_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
open_detail ();
});

delete_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
delete_request ();
});

add_item.activate_item.connect (() => {
menu_handle_popover.popdown ();

var dialog = new Dialogs.QuickAdd ();
dialog.for_base_object (item);
dialog.present (Planify._instance.main_window);
});

duplicate_item.clicked.connect (() => {
menu_handle_popover.popdown ();
Util.get_default ().duplicate_item.begin (item, item.project_id, item.section_id, item.parent_id);
});
}
Expand Down
18 changes: 0 additions & 18 deletions src/Layouts/ItemRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,6 @@ public class Layouts.ItemRow : Layouts.ItemBase {
menu_handle_popover.popup ();

move_item.activate_item.connect (() => {
menu_handle_popover.popdown ();

Dialogs.ProjectPicker.ProjectPicker dialog;
if (item.project.is_inbox_project) {
dialog = new Dialogs.ProjectPicker.ProjectPicker.for_projects ();
Expand All @@ -1139,51 +1137,41 @@ public class Layouts.ItemRow : Layouts.ItemBase {
});

today_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
update_date (Utils.Datetime.get_date_only (new DateTime.now_local ()));
});

tomorrow_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
update_date (Utils.Datetime.get_date_only (new DateTime.now_local ().add_days (1)));
});

pinboard_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
item.update_pin (!item.pinned);
});

no_date_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
update_date (null);
});

complete_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
checked_button.active = !checked_button.active;
checked_toggled (checked_button.active);
});

edit_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
Services.EventBus.get_default ().open_item (item);
});

delete_item.activate_item.connect (() => {
menu_handle_popover.popdown ();
delete_request ();
});

add_item.activate_item.connect (() => {
menu_handle_popover.popdown ();

var dialog = new Dialogs.QuickAdd ();
dialog.for_base_object (item);
dialog.present (Planify._instance.main_window);
});

duplicate_item.clicked.connect (() => {
menu_handle_popover.popdown ();
Util.get_default ().duplicate_item.begin (item, item.project_id, item.section_id, item.parent_id);
});
}
Expand Down Expand Up @@ -1232,18 +1220,14 @@ public class Layouts.ItemRow : Layouts.ItemBase {
});

copy_clipboard_item.clicked.connect (() => {
popover.popdown ();
item.copy_clipboard ();
});

duplicate_item.clicked.connect (() => {
popover.popdown ();
Util.get_default ().duplicate_item.begin (item, item.project_id, item.section_id, item.parent_id);
});

move_item.clicked.connect (() => {
popover.popdown ();

Dialogs.ProjectPicker.ProjectPicker dialog;
if (item.project.is_inbox_project) {
dialog = new Dialogs.ProjectPicker.ProjectPicker.for_projects ();
Expand All @@ -1265,12 +1249,10 @@ public class Layouts.ItemRow : Layouts.ItemBase {
});

delete_item.activate_item.connect (() => {
popover.popdown ();
delete_request ();
});

more_information_item.activate_item.connect (() => {
popover.popdown ();
var dialog = new Dialogs.ItemChangeHistory (item);
dialog.present (Planify._instance.main_window);
});
Expand Down
6 changes: 0 additions & 6 deletions src/Layouts/ItemSidebarView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -490,18 +490,14 @@ public class Layouts.ItemSidebarView : Adw.Bin {
});

copy_clipboard_item.clicked.connect (() => {
popover.popdown ();
item.copy_clipboard ();
});

duplicate_item.clicked.connect (() => {
popover.popdown ();
Util.get_default ().duplicate_item.begin (item, item.project_id, item.section_id, item.parent_id);
});

move_item.clicked.connect (() => {
popover.popdown ();

Dialogs.ProjectPicker.ProjectPicker dialog;
if (item.project.is_inbox_project) {
dialog = new Dialogs.ProjectPicker.ProjectPicker.for_projects ();
Expand All @@ -524,12 +520,10 @@ public class Layouts.ItemSidebarView : Adw.Bin {
});

delete_item.activate_item.connect (() => {
popover.popdown ();
delete_request ();
});

more_information_item.activate_item.connect (() => {
popover.popdown ();
var dialog = new Dialogs.ItemChangeHistory (item);
dialog.present (Planify._instance.main_window);
});
Expand Down
2 changes: 0 additions & 2 deletions src/Layouts/LabelRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ public class Layouts.LabelRow : Gtk.ListBoxRow {
};

edit_item.clicked.connect (() => {
menu_popover.popdown ();
var dialog = new Dialogs.Label (label);
dialog.present (Planify._instance.main_window);
});

delete_item.clicked.connect (() => {
menu_popover.popdown ();
label.delete_label (Planify._instance.main_window);
});

Expand Down
10 changes: 0 additions & 10 deletions src/Layouts/ProjectRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -711,48 +711,38 @@ public class Layouts.ProjectRow : Gtk.ListBoxRow {
menu_popover.popup ();

favorite_item.clicked.connect (() => {
menu_popover.popdown ();

project.is_favorite = !project.is_favorite;
Services.Store.instance ().update_project (project);
Services.EventBus.get_default ().favorite_toggled (project);
project.update ();
});

edit_item.clicked.connect (() => {
menu_popover.popdown ();

var dialog = new Dialogs.Project (project);
dialog.present (Planify._instance.main_window);
});

refresh_item.clicked.connect (() => {
menu_popover.popdown ();
sync_project ();
});

delete_item.clicked.connect (() => {
menu_popover.popdown ();
project.delete_project ((Gtk.Window) Planify.instance.main_window);
});

share_markdown_item.clicked.connect (() => {
menu_popover.popdown ();
project.share_markdown ();
});

share_email_item.clicked.connect (() => {
menu_popover.popdown ();
project.share_mail ();
});

duplicate_item.clicked.connect (() => {
menu_popover.popdown ();
Util.get_default ().duplicate_project.begin (project, project.parent_id);
});

archive_item.clicked.connect (() => {
menu_popover.popdown ();
project.archive_project ((Gtk.Window) Planify.instance.main_window);
});
}
Expand Down
13 changes: 0 additions & 13 deletions src/Layouts/SectionBoard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -502,20 +502,15 @@ public class Layouts.SectionBoard : Gtk.FlowBoxChild {
};

add_item.clicked.connect (() => {
menu_popover.popdown ();
prepare_new_item ();
});

edit_item.clicked.connect (() => {
menu_popover.popdown ();

var dialog = new Dialogs.Section (section);
dialog.present (Planify._instance.main_window);
});

move_item.clicked.connect (() => {
menu_popover.popdown ();

var dialog = new Dialogs.ProjectPicker.ProjectPicker.for_project (section.source);
dialog.project = section.project;
dialog.present (Planify._instance.main_window);
Expand All @@ -528,20 +523,15 @@ public class Layouts.SectionBoard : Gtk.FlowBoxChild {
});

manage_item.clicked.connect (() => {
menu_popover.popdown ();

var dialog = new Dialogs.ManageSectionOrder (section.project);
dialog.present (Planify._instance.main_window);
});

archive_item.clicked.connect (() => {
menu_popover.popdown ();
section.archive_section ((Gtk.Window) Planify.instance.main_window);
});

delete_item.clicked.connect (() => {
menu_popover.popdown ();

var dialog = new Adw.AlertDialog (
_("Delete Section %s".printf (section.name)),
_("This can not be undone")
Expand Down Expand Up @@ -569,15 +559,12 @@ public class Layouts.SectionBoard : Gtk.FlowBoxChild {
});

show_completed_item.clicked.connect (() => {
menu_popover.popdown ();

var dialog = new Dialogs.CompletedTasks (section.project);
dialog.add_update_filter (section);
dialog.present (Planify._instance.main_window);
});

duplicate_item.clicked.connect (() => {
menu_popover.popdown ();
Util.get_default ().duplicate_section.begin (section, section.project_id);
});

Expand Down
Loading

0 comments on commit 2d7d11d

Please sign in to comment.