Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PopoverMenuitem #394

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ executable(
'src/Widgets/EntryPopover/DateTime.vala',
'src/Widgets/EntryPopover/Generic.vala',
'src/Widgets/EntryPopover/Location.vala',
'src/Widgets/PopoverMenuitem.vala',
'src/Widgets/ScheduledRow.vala',
'src/Widgets/SourceRow.vala',
'src/Widgets/ScheduledTaskListBox.vala',
Expand Down
4 changes: 2 additions & 2 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {

add_tasklist_buttonbox = new Gtk.Box (VERTICAL, 3);

var online_accounts_button = new Gtk.ModelButton () {
var online_accounts_button = new PopoverMenuitem () {
text = _("Online Accounts Settings…")
};

Expand Down Expand Up @@ -389,7 +389,7 @@ public class Tasks.MainWindow : Hdy.ApplicationWindow {
}
collection_sources.add (collection_source);

var source_button = new Gtk.ModelButton () {
var source_button = new PopoverMenuitem () {
text = Util.get_esource_collection_display_name (collection_source),
sensitive = Application.model.is_add_task_list_supported (collection_source)
};
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/EntryPopover/DateTime.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Tasks.Widgets.EntryPopover.DateTime : Generic<GLib.DateTime?> {
margin_top = 3
};

var today_button = new Gtk.ModelButton () {
var today_button = new PopoverMenuitem () {
text = _("Today")
};

Expand Down
13 changes: 4 additions & 9 deletions src/Widgets/ListSettingsPopover.vala
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ public class Tasks.Widgets.ListSettingsPopover : Gtk.Popover {
margin_top = 3
};

var delete_list_accel_label = new Granite.AccelLabel.from_action_name (
_("Delete List…"),
MainWindow.ACTION_PREFIX + MainWindow.ACTION_DELETE_SELECTED_LIST
);

var delete_list_menuitem = new Gtk.ModelButton ();
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);
var delete_list_menuitem = new PopoverMenuitem () {
action_name = MainWindow.ACTION_PREFIX + MainWindow.ACTION_DELETE_SELECTED_LIST,
text = _("Delete List…")
};
delete_list_menuitem.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);

var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
Expand Down
31 changes: 31 additions & 0 deletions src/Widgets/PopoverMenuitem.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/

class Tasks.PopoverMenuitem : Gtk.Button {
public string text {
set {
child = new Granite.AccelLabel (value) {
action_name = this.action_name
};

get_accessible ().accessible_name = value;
}
}

class construct {
set_css_name ("modelbutton");
}

construct {
set_accessible_role (Atk.Role.MENU_ITEM);

clicked.connect (() => {
var popover = (Gtk.Popover) get_ancestor (typeof (Gtk.Popover));
if (popover != null) {
popover.popdown ();
}
});
}
}