<commit_before>/*
 * Fader.cs
 *
 * Copyright 2007 Novell Inc.
 *
 * Author
 *   <NAME> <<EMAIL>>
 *
 * See COPYING for license information.
 *
 */
using System;
using Gtk;
using FSpot.Widgets;

namespace FSpot {
	public class Fader {
		bool composited;
		Delay fade_delay;
		TimeSpan duration;
		DateTime start;
		Gtk.Window win;
		double target_opacity;
		
		public Fader (Gtk.Window win, double target, int sec)
		{
			this.win = win;
			win.Mapped += HandleMapped;
			win.Unmapped += HandleUnmapped;
			win.ExposeEvent += HandleExposeEvent;
			duration = new TimeSpan (0, 0, sec);
			target_opacity = target;
		}
		
		[GLib.ConnectBefore]
		public void HandleMapped (object sender, EventArgs args)
		{
			composited = CompositeUtils.SupportsHint (win.Screen, "_NET_WM_WINDOW_OPACITY");
			if (!composited)
				return;
			
			CompositeUtils.SetWinOpacity (win, 0.0);
		}
		
		public void HandleExposeEvent (object sender, ExposeEventArgs args)
		{
			if (fade_delay == null) {
				fade_delay = new Delay (50, new GLib.IdleHandler (Update));
					start = DateTime.Now;
					fade_delay.Start ();
			}
		}
		
		public void HandleUnmapped (object sender, EventArgs args)
		{
			if (fade_delay != null)
				fade_delay.Stop ();
		}
		
		public bool Update ()
		{
			double percent = Math.Min ((DateTime.Now - start).Ticks / (double) duration.Ticks, 1.0);
			double opacity = Math.Sin (percent * Math.PI * 0.5) * target_opacity;
			CompositeUtils.SetWinOpacity (win, opacity);
			
			bool stop = opacity >= target_opacity;

			if (stop)
				fade_delay.Stop ();
			
			return !stop;
		}
	}
}<commit_msg>don't expect Expose event on Fader<commit_after>/*
 * Fader.cs
 *
 * Copyright 2007 Novell Inc.
 *
 * Author
 *   <NAME> <<EMAIL>>
 *
 * See COPYING for license information.
 *
 */
using System;
using Gtk;
using FSpot.Widgets;
using FSpot.Bling;

namespace FSpot {
	public class Fader {
		bool composited;
		Gtk.Window win;
		double target_opacity;
		DoubleAnimation fadin;

		public Fader (Gtk.Window win, double target, int sec)
		{
			this.win = win;
			win.Mapped += HandleMapped;
			win.Unmapped += HandleUnmapped;
			fadin = new DoubleAnimation (0.0, target, new TimeSpan (0, 0, sec), delegate (double opacity) {
				CompositeUtils.SetWinOpacity (win, opacity);
			});	
		}
		
		[GLib.ConnectBefore]
		public void HandleMapped (object sender, EventArgs args)
		{
			composited = CompositeUtils.SupportsHint (win.Screen, "_NET_WM_WINDOW_OPACITY");
			if (!composited)
				return;
			
			CompositeUtils.SetWinOpacity (win, 0.0);
			fadin.Start ();
		}
		
		public void HandleUnmapped (object sender, EventArgs args)
		{
			fadin.Stop ();
		}
	}
}
{'fraction_non_alphanumeric': 0.11442598187311179, 'fraction_numerical': 0.00906344410876133, 'mean_word_length': 3.2114467408585057, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1817806', 'n_tokens_mistral': 1091, 'n_tokens_neox': 904, 'n_words': 237}