From 5f45b6bb13a5c3c180b8fcd2a90059baecb82b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 17 Feb 2026 09:33:21 -0800 Subject: [PATCH 1/3] GuestsPanel: GObject style, cleanup --- src/EventEdition/EventDialog.vala | 2 +- src/EventEdition/GuestsPanel.vala | 117 +++++++++++++----------------- 2 files changed, 52 insertions(+), 67 deletions(-) diff --git a/src/EventEdition/EventDialog.vala b/src/EventEdition/EventDialog.vala index cdc4946ff..572fda288 100644 --- a/src/EventEdition/EventDialog.vala +++ b/src/EventEdition/EventDialog.vala @@ -68,7 +68,7 @@ public class EventDialog : Granite.Dialog { event_type = EventType.EDIT; } - guests_panel = new EventEdition.GuestsPanel (this); + guests_panel = new EventEdition.GuestsPanel (ecal.get_icalcomponent ()); info_panel = new EventEdition.InfoPanel (this); location_panel = new EventEdition.LocationPanel (this); reminder_panel = new EventEdition.ReminderPanel (this); diff --git a/src/EventEdition/GuestsPanel.vala b/src/EventEdition/GuestsPanel.vala index 926a0a5d7..014ab284a 100644 --- a/src/EventEdition/GuestsPanel.vala +++ b/src/EventEdition/GuestsPanel.vala @@ -1,25 +1,13 @@ -// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- -/*- - * Copyright (c) 2011-2015 Maya Developers (http://launchpad.net/maya) - * - * 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, see . +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2011-2026 elementary, Inc. (https://elementary.io) * * Authored by: Jaap Broekhuizen */ -public class Maya.View.EventEdition.GuestsPanel : Gtk.Grid { - private EventDialog parent_dialog; +public class Maya.View.EventEdition.GuestsPanel : Gtk.Box { + public ICal.Component component { get; construct; } + private Gtk.Entry guest_entry; private Gtk.EntryCompletion guest_completion; private Gtk.ListBox guest_list; @@ -38,37 +26,36 @@ public class Maya.View.EventEdition.GuestsPanel : Gtk.Grid { N_COLUMNS; } - public GuestsPanel (EventDialog parent_dialog) { - this.parent_dialog = parent_dialog; - attendees = new Gee.ArrayList (); + public GuestsPanel (ICal.Component component) { + Object (component: component); + } - margin_start = 12; - margin_end = 12; - row_spacing = 6; - set_sensitive (parent_dialog.can_edit); - orientation = Gtk.Orientation.VERTICAL; + construct { + attendees = new Gee.ArrayList (); guest_store = new Gtk.ListStore (2, typeof (string), typeof (string)); - var guest_label = new Granite.HeaderLabel (_("Invitees")); - load_contacts.begin (); var no_guests_label = new Gtk.Label (_("No Invitees")); + no_guests_label.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL); + no_guests_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); no_guests_label.show (); - unowned Gtk.StyleContext no_guests_context = no_guests_label.get_style_context (); - no_guests_context.add_class (Granite.STYLE_CLASS_H3_LABEL); - no_guests_context.add_class (Gtk.STYLE_CLASS_DIM_LABEL); - - guest_list = new Gtk.ListBox (); - guest_list.set_selection_mode (Gtk.SelectionMode.NONE); + guest_list = new Gtk.ListBox () { + hexpand = true, + vexpand = true, + selection_mode = NONE + }; guest_list.set_placeholder (no_guests_label); + var guest_label = new Granite.HeaderLabel (_("Invitees")) { + mnemonic_widget = guest_list + }; + var guest_scrolledwindow = new Gtk.ScrolledWindow (null, null) { - child = guest_list + child = guest_list, }; - guest_scrolledwindow.expand = true; var frame = new Gtk.Frame (null) { child = guest_scrolledwindow @@ -94,34 +81,33 @@ public class Maya.View.EventEdition.GuestsPanel : Gtk.Grid { return false; }); - guest_entry = new Gtk.SearchEntry (); - guest_entry.placeholder_text = _("Invite"); - guest_entry.hexpand = true; + guest_entry = new Gtk.SearchEntry () { + hexpand = true, + placeholder_text = _("Invite") + }; guest_entry.set_completion (guest_completion); guest_entry.activate.connect (() => { - var attendee = new ICal.Property (ICal.PropertyKind.ATTENDEE_PROPERTY); + var attendee = new ICal.Property (ATTENDEE_PROPERTY); attendee.set_attendee (guest_entry.text); add_guest ((owned)attendee); guest_entry.delete_text (0, -1); }); + margin_start = 12; + margin_end = 12; + spacing = 6; + orientation = VERTICAL; add (guest_label); add (guest_entry); add (frame); - if (parent_dialog.ecal != null) { - unowned ICal.Component comp = parent_dialog.ecal.get_icalcomponent (); - // Load the guests - int count = comp.count_properties (ICal.PropertyKind.ATTENDEE_PROPERTY); - - ICal.Property property; - property = comp.get_first_property (ICal.PropertyKind.ATTENDEE_PROPERTY); - for (int i = 0; i < count; i++) { - if (property.get_attendee () != null) - add_guest (property); - - property = comp.get_next_property (ICal.PropertyKind.ATTENDEE_PROPERTY); + var property = component.get_first_property (ATTENDEE_PROPERTY); + for (int i = 0; i < component.count_properties (ATTENDEE_PROPERTY); i++) { + if (property.get_attendee () != null) { + add_guest (property); } + + property = component.get_next_property (ATTENDEE_PROPERTY); } show_all (); @@ -145,17 +131,13 @@ public class Maya.View.EventEdition.GuestsPanel : Gtk.Grid { * Save the values in the dialog into the component. */ public void save () { - unowned ICal.Component comp = parent_dialog.ecal.get_icalcomponent (); - // Save the guests // First, clear the guests - int count = comp.count_properties (ICal.PropertyKind.ATTENDEE_PROPERTY); - - for (int i = 0; i < count; i++) { + for (int i = 0; i < component.count_properties (ATTENDEE_PROPERTY); i++) { ICal.Property remove_prop; if (i == 0) { - remove_prop = comp.get_first_property (ICal.PropertyKind.ATTENDEE_PROPERTY); + remove_prop = component.get_first_property (ATTENDEE_PROPERTY); } else { - remove_prop = comp.get_next_property (ICal.PropertyKind.ATTENDEE_PROPERTY); + remove_prop = component.get_next_property (ATTENDEE_PROPERTY); } ICal.Property found_prop = remove_prop; @@ -168,7 +150,7 @@ public class Maya.View.EventEdition.GuestsPanel : Gtk.Grid { } if (can_remove == true) { - comp.remove_property (remove_prop); + component.remove_property (remove_prop); } else if (found_prop != remove_prop) { attendees.remove (found_prop); } @@ -176,26 +158,29 @@ public class Maya.View.EventEdition.GuestsPanel : Gtk.Grid { // Add the new guests foreach (unowned ICal.Property attendee in attendees) { - comp.add_property (attendee.clone ()); + component.add_property (attendee.clone ()); } } private void add_guest (ICal.Property attendee) { - var row = new Gtk.ListBoxRow (); var guest_element = new GuestGrid (attendee); - row.add (guest_element); + + var row = new Gtk.ListBoxRow () { + child = guest_element + }; + row.show_all (); + guest_list.add (row); attendees.add (guest_element.attendee); + guest_element.removed.connect (() => { attendees.remove (guest_element.attendee); }); - - row.show_all (); } private bool suggestion_selected (Gtk.TreeModel model, Gtk.TreeIter iter) { - var attendee = new ICal.Property (ICal.PropertyKind.ATTENDEE_PROPERTY); + var attendee = new ICal.Property (ATTENDEE_PROPERTY); Value selected_value; model.get_value (iter, 1, out selected_value); From 398d750628f36b0fba4a7aaf61cf779d377e7ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 17 Feb 2026 09:36:48 -0800 Subject: [PATCH 2/3] Extra comma --- src/EventEdition/GuestsPanel.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EventEdition/GuestsPanel.vala b/src/EventEdition/GuestsPanel.vala index 014ab284a..7bacaf8de 100644 --- a/src/EventEdition/GuestsPanel.vala +++ b/src/EventEdition/GuestsPanel.vala @@ -54,7 +54,7 @@ public class Maya.View.EventEdition.GuestsPanel : Gtk.Box { }; var guest_scrolledwindow = new Gtk.ScrolledWindow (null, null) { - child = guest_list, + child = guest_list }; var frame = new Gtk.Frame (null) { From 8d76cbe9ca03463ced12675057524a3773069a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 17 Feb 2026 11:35:54 -0800 Subject: [PATCH 3/3] explicit margins --- src/EventEdition/GuestGrid.vala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/EventEdition/GuestGrid.vala b/src/EventEdition/GuestGrid.vala index 023116a1b..d5794fa24 100644 --- a/src/EventEdition/GuestGrid.vala +++ b/src/EventEdition/GuestGrid.vala @@ -47,7 +47,10 @@ public class Maya.View.EventEdition.GuestGrid : Gtk.Grid { avatar = new Hdy.Avatar (ICON_SIZE, name_label.label, true); column_spacing = 12; - margin = 6; + margin_top = 6; + margin_end = 6; + margin_bottom = 6; + margin_start = 6; attach (avatar, 0, 0, 1, 4); attach (name_label, 1, 1); attach (mail_label, 1, 2);