11/*
2- * Copyright 2011-2018 elementary, Inc. (https://elementary.io)
3- *
4- * This program is free software: you can redistribute it and/or modify
5- * it under the terms of the GNU General Public License as published by
6- * the Free Software Foundation, either version 3 of the License, or
7- * (at your option) any later version.
8- *
9- * This program is distributed in the hope that it will be useful,
10- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12- * GNU General Public License for more details.
13- *
14- * You should have received a copy of the GNU General Public License
15- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2+ * SPDX-License-Identifier: GPL-3.0-or-later
3+ * SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io)
164 *
175 * Authored by: Maxwell Barvian
186 * Corentin Noël <corentin@elementaryos.org>
197 */
208
21- public class Maya.View.EventButton : Gtk .Revealer {
9+ public class Maya.View.EventButton : Gtk .Bin {
2210 public ECal . Component comp { get ; construct set ; }
2311
12+ private Gtk . Revealer revealer;
2413 private Gtk . Label label;
2514 private Gtk . StyleContext grid_style_context;
2615
@@ -34,12 +23,11 @@ public class Maya.View.EventButton : Gtk.Revealer {
3423 }
3524
3625 construct {
37- transition_type = Gtk . RevealerTransitionType . CROSSFADE ;
38-
39- label = new Gtk .Label (comp. get_summary (). get_value ());
40- label. hexpand = true ;
41- label. ellipsize = Pango . EllipsizeMode . END ;
42- label. xalign = 0 ;
26+ label = new Gtk .Label (comp. get_summary (). get_value ()) {
27+ hexpand = true ,
28+ ellipsize = END ,
29+ xalign = 0
30+ };
4331 label. show ();
4432
4533 var internal_grid = new Gtk .Grid ();
@@ -51,7 +39,12 @@ public class Maya.View.EventButton : Gtk.Revealer {
5139 var event_box = new Gtk .EventBox ();
5240 event_box. add (internal_grid);
5341
54- add (event_box);
42+ revealer = new Gtk .Revealer () {
43+ child = event_box,
44+ transition_type = CROSSFADE
45+ };
46+
47+ child = revealer;
5548
5649 var context_menu = Maya . EventMenu . build (comp);
5750 context_menu. attach_to_widget (this , null );
@@ -143,10 +136,36 @@ public class Maya.View.EventButton : Gtk.Revealer {
143136 }
144137
145138 public void destroy_button () {
146- set_reveal_child ( false ) ;
147- Timeout . add (transition_duration, () = > {
139+ revealer . reveal_child = false ;
140+ Timeout . add (revealer . transition_duration, () = > {
148141 destroy ();
149142 return false ;
150143 });
151144 }
145+
146+ public void hide_without_animate () {
147+ if (! revealer. child_revealed) {
148+ return ;
149+ }
150+
151+ var reveal_duration = revealer. transition_duration;
152+ revealer. transition_duration = 0 ;
153+ revealer. reveal_child = false ;
154+ revealer. transition_duration = reveal_duration;
155+
156+ hide ();
157+ }
158+
159+ public void show_without_animate () {
160+ show ();
161+
162+ if (revealer. child_revealed) {
163+ return ;
164+ }
165+
166+ var reveal_duration = revealer. transition_duration;
167+ revealer. transition_duration = 0 ;
168+ revealer. reveal_child = true ;
169+ revealer. transition_duration = reveal_duration;
170+ }
152171}
0 commit comments