Example #1
0
        /// <summary>
        /// Handles when a weather source successfully reloads data.
        /// </summary>
        void HandleWeatherUpdated()
        {
            DockServices.System.RunOnMainThread(delegate {
                AbstractWeatherSource weather = WeatherController.Weather;

                string feelsLike = "";
                if (weather.ShowFeelsLike)
                {
                    feelsLike = " (" + weather.FeelsLike + AbstractWeatherSource.TempUnit + ")";
                }

                HoverText = weather.Condition + "   " +
                            weather.Temp + AbstractWeatherSource.TempUnit + feelsLike +
                            "   " + weather.City;
                Icon   = WeatherController.Weather.Image;
                Status = WeatherDockletStatus.Normal;
                State &= ~ItemState.Wait;

                QueueRedraw();

                if (painter != null)
                {
                    painter.WeatherChanged();
                }
            });
        }
Example #2
0
 /// <summary>
 /// Handles an error with the weather source.
 /// </summary>
 /// <param name="sender">
 /// Ignored
 /// </param>
 /// <param name="e">
 /// A <see cref="WeatherErrorArgs"/> which contains the error message.
 /// </param>
 void HandleWeatherError(object sender, WeatherErrorArgs e)
 {
     DockServices.System.RunOnMainThread(delegate {
         HoverText = e.Error;
         Icon      = "weather-few-clouds";
         Status    = WeatherDockletStatus.Error;
         State    &= ~ItemState.Wait;
         QueueRedraw();
     });
 }
Example #3
0
        /// <summary>
        /// Creates a new weather docklet.
        /// </summary>
        public WeatherDocklet()
        {
            ScalableRendering = false;

            painter = new WeatherPainter();

            Status = WeatherDockletStatus.Initializing;

            WeatherController.WeatherReloading += HandleWeatherReloading;
            WeatherController.WeatherError     += HandleWeatherError;
            WeatherController.WeatherUpdated   += HandleWeatherUpdated;

            HoverText = Catalog.GetString("Click to add a location.");
            Icon      = "weather-few-clouds";
        }
		/// <summary>
		/// Creates a new weather docklet.
		/// </summary>
		public WeatherDocklet ()
		{
			ScalableRendering = false;
			
			painter = new WeatherPainter ();
			
			Status = WeatherDockletStatus.Initializing;
			
			WeatherController.WeatherReloading += HandleWeatherReloading;
			WeatherController.WeatherError += HandleWeatherError;
			WeatherController.WeatherUpdated += HandleWeatherUpdated;
			
			HoverText = Catalog.GetString ("Click to add a location.");
			Icon = "weather-few-clouds";
		}
Example #5
0
 /// <summary>
 /// Handles when a weather source reloads data.
 /// </summary>
 void HandleWeatherReloading()
 {
     DockServices.System.RunOnMainThread(delegate {
         HoverText = Catalog.GetString("Fetching data...");
         if (Status != WeatherDockletStatus.Initializing && Status != WeatherDockletStatus.ManualReload)
         {
             Status = WeatherDockletStatus.Reloading;
             State &= ~ItemState.Wait;
         }
         else
         {
             State |= ItemState.Wait;
         }
         QueueRedraw();
     });
 }
Example #6
0
        protected override MenuList OnGetMenuItems()
        {
            MenuList list = base.OnGetMenuItems();

            if (WeatherController.Weather.Condition != null)
            {
                list[MenuListContainer.Header].Add(new MenuItem(Catalog.GetString("Radar _Map"),
                                                                WeatherController.Weather.Image, (o, a) => WeatherController.Weather.ShowRadar()));
            }


            list.SetContainerTitle(MenuListContainer.Actions, Mono.Unix.Catalog.GetString("Forecasts"));
            for (int i = 0; i < WeatherController.Weather.ForecastDays; i++)
            {
                if (WeatherController.Weather.Forecasts [i].dow != null)
                {
                    list[MenuListContainer.Actions].Add(new ForecastMenuItem(i,
                                                                             string.Format("{0}", WeatherForecast.DayName(WeatherController.Weather.Forecasts [i].dow)), WeatherController.Weather.Forecasts [i].image));
                }
            }

            list[MenuListContainer.CustomOne].Add(new MenuItem(Catalog.GetString("_Settings"), Gtk.Stock.Preferences,
                                                               delegate {
                if (Config == null)
                {
                    Config = new WeatherConfigDialog();
                }
                Config.Show();
            }));

            if (WeatherController.CurrentLocation != "")
            {
                list[MenuListContainer.CustomOne].Add(new MenuItem(Catalog.GetString("Check _Weather"), Gtk.Stock.Refresh,
                                                                   delegate {
                    Status = WeatherDockletStatus.ManualReload;
                    State |= ItemState.Wait;
                    QueueRedraw();
                    WeatherController.ResetTimer();
                }));
            }

            return(list);
        }
Example #7
0
        protected override void OnScrolled(Gdk.ScrollDirection direction, Gdk.ModifierType mod)
        {
            if (WeatherPreferences.Locations.Length <= 1)
            {
                return;
            }

            Status = WeatherDockletStatus.ManualReload;
            State |= ItemState.Wait;
            QueueRedraw();

            if (direction == Gdk.ScrollDirection.Up)
            {
                WeatherController.PreviousLocation();
            }
            else
            {
                WeatherController.NextLocation();
            }
        }
		/// <summary>
		/// Handles when a weather source reloads data.
		/// </summary>
		void HandleWeatherReloading ()
		{
			DockServices.System.RunOnMainThread (delegate {
				HoverText = Catalog.GetString ("Fetching data...");
				if (Status != WeatherDockletStatus.Initializing && Status != WeatherDockletStatus.ManualReload) {
					Status = WeatherDockletStatus.Reloading;
					State &= ~ItemState.Wait;
				} else {
					State |= ItemState.Wait;
				}
				QueueRedraw ();
			});
		}
		protected override MenuList OnGetMenuItems ()
		{
			MenuList list = base.OnGetMenuItems ();
			
			if (WeatherController.Weather.Condition != null)
			{
				list[MenuListContainer.Header].Add (new MenuItem (Catalog.GetString ("Radar _Map"),
						WeatherController.Weather.Image, (o, a) => WeatherController.Weather.ShowRadar ()));
			}
			
			
			list.SetContainerTitle (MenuListContainer.Actions, Mono.Unix.Catalog.GetString ("Forecasts"));
			for (int i = 0; i < WeatherController.Weather.ForecastDays; i++)
				if (WeatherController.Weather.Forecasts [i].dow != null)
				{
					list[MenuListContainer.Actions].Add (new ForecastMenuItem (i,
							string.Format ("{0}", WeatherForecast.DayName (WeatherController.Weather.Forecasts [i].dow)), WeatherController.Weather.Forecasts [i].image));
				}
			
			list[MenuListContainer.CustomOne].Add (new MenuItem (Catalog.GetString ("_Settings"), Gtk.Stock.Preferences, 
					delegate {
						if (Config == null)
							Config = new WeatherConfigDialog ();
						Config.Show ();
					}));
			
			if (WeatherController.CurrentLocation != "")
				list[MenuListContainer.CustomOne].Add (new MenuItem (Catalog.GetString ("Check _Weather"), Gtk.Stock.Refresh,
						delegate {
							Status = WeatherDockletStatus.ManualReload;
							State |= ItemState.Wait;
							QueueRedraw ();
							WeatherController.ResetTimer ();
						}));
			
			return list;
		}
		protected override void OnScrolled (Gdk.ScrollDirection direction, Gdk.ModifierType mod)
		{
			if (WeatherPreferences.Locations.Length <= 1)
				return;

			Status = WeatherDockletStatus.ManualReload;
			State |= ItemState.Wait;
			QueueRedraw ();
			
			if (direction == Gdk.ScrollDirection.Up)
				WeatherController.PreviousLocation ();
			else
				WeatherController.NextLocation ();
		}
		/// <summary>
		/// Handles when a weather source successfully reloads data.
		/// </summary>
		void HandleWeatherUpdated ()
		{
			DockServices.System.RunOnMainThread (delegate {
				AbstractWeatherSource weather = WeatherController.Weather;
				
				string feelsLike = "";
				if (weather.ShowFeelsLike)
					feelsLike = " (" + weather.FeelsLike + AbstractWeatherSource.TempUnit + ")";
				
				HoverText = weather.Condition + "   " +
					weather.Temp + AbstractWeatherSource.TempUnit + feelsLike +
					"   " + weather.City;
				Icon = WeatherController.Weather.Image;
				Status = WeatherDockletStatus.Normal;
				State &= ~ItemState.Wait;
				
				QueueRedraw ();
				
				if (painter != null) 
					painter.WeatherChanged ();
			});
		}
		/// <summary>
		/// Handles an error with the weather source.
		/// </summary>
		/// <param name="sender">
		/// Ignored
		/// </param>
		/// <param name="e">
		/// A <see cref="WeatherErrorArgs"/> which contains the error message.
		/// </param>
		void HandleWeatherError (object sender, WeatherErrorArgs e)
		{
			DockServices.System.RunOnMainThread (delegate {
				HoverText = e.Error;
				Icon = "weather-few-clouds";
				Status = WeatherDockletStatus.Error;
				State &= ~ItemState.Wait;
				QueueRedraw ();
			});
		}