Skip to content

Commit

Permalink
fixed missing icons when not using gnome
Browse files Browse the repository at this point in the history
  • Loading branch information
SalaniLeo committed May 25, 2023
1 parent a328b69 commit 29ee000
Show file tree
Hide file tree
Showing 35 changed files with 2,068 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Forecast/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ def __init__(self, *args, **kwargs):
def start_application(main_window):

# starts main thread
wttr_thrd = Thread(target=main_page, args=(None, main_window, None))
wttr_thrd = Thread(target=main_page, args=(None, main_window, None, flatpak))
wttr_thrd.start()

def add_city(button, active, main_window, name):
if name is None:
main_page(None, main_window, name)
main_page(None, main_window, name, flatpak)



Expand Down
82 changes: 46 additions & 36 deletions Forecast/WttrInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
css_class = None
saved_locations = settings.get_strv('wthr-locs')

css_provider = Gtk.CssProvider()

title = None

both_update = True #TODO
Expand All @@ -30,10 +28,13 @@

forecast_box = Gtk.Box(spacing=24, orientation=Gtk.Orientation.HORIZONTAL)

icon_loc = None

class main_page(Gtk.Box):
def __init__(self, thread, window, name):
def __init__(self, thread, window, name, flatpak):
super().__init__()

global icon_loc
global meteo
global lat
global lon
Expand All @@ -43,6 +44,13 @@ def __init__(self, thread, window, name):
else:
text_raw = saved_locations[0]

if flatpak:
icon_loc = '/app/share/icons/hicolor/scalable/status/'
# elif appimage:
# icon_loc.load_from_path('style.css')
else:
icon_loc = 'data/status/'

coords_raw = text_raw[text_raw.find("(")+1:text_raw.find(")")]

lat = coords_raw.split("; ")[0]
Expand Down Expand Up @@ -377,41 +385,43 @@ def set_frcst_icon(forecast):

img = Gtk.Image()
img.set_pixel_size(35)

print(icon_loc + icon_id)

if icon_id == "01d":
img.set_from_icon_name('weather-clear-large')
img.set_from_file(icon_loc + 'weather-clear-large.svg')
elif icon_id == "02d" or icon_id == "03d":
img.set_from_icon_name('weather-few-clouds-large')
img.set_from_file(icon_loc + 'weather-few-clouds-large.svg')
elif icon_id == "04d":
img.set_from_icon_name('weather-overcast-large')
img.set_from_file(icon_loc + 'weather-overcast-large.svg')
elif icon_id == "09d":
img.set_from_icon_name('weather-showers-scattered-large')
img.set_from_file(icon_loc + 'weather-showers-scattered-large.svg')
elif icon_id == "10d":
img.set_from_icon_name('weather-showers-large')
img.set_from_file(icon_loc + 'weather-showers-large.svg')
elif icon_id == "11d":
img.set_from_icon_name('weather-storm-large')
img.set_from_file(icon_loc + 'weather-storm-large.svg')
elif icon_id == "13d":
img.set_from_icon_name('weather-snow-large')
img.set_from_file(icon_loc + 'weather-snow-large.svg')
elif icon_id == "50d":
img.set_from_icon_name('weather-fog-large')
img.set_from_file(icon_loc + 'weather-fog-large.svg')

# -------- night icon_ids --------- #
elif icon_id == "01n":
img.set_from_icon_name('weather-clear-night-symbolic')
img.set_from_file(icon_loc + 'weather-clear-night-large.svg')
elif icon_id == "02n" or icon_id == "03n":
img.set_from_icon_name('weather-few-clouds-night-large')
img.set_from_file(icon_loc + 'weather-few-clouds-night-large.svg')
elif icon_id == "04n":
img.set_from_icon_name('weather-overcast-large')
img.set_from_file(icon_loc + 'weather-overcast-large.svg')
elif icon_id == "09n":
img.set_from_icon_name('weather-showers-scattered-large')
img.set_from_file(icon_loc + 'weather-showers-scattered-large.svg')
elif icon_id == "10n":
img.set_from_icon_name('weather-showers-large')
img.set_from_file(icon_loc + 'weather-showers-large.svg')
elif icon_id == "11n":
img.set_from_icon_name('weather-storm-large')
img.set_from_file(icon_loc + 'weather-storm-large.svg')
elif icon_id == "13n":
img.set_from_icon_name('weather-snow-large')
img.set_from_file(icon_loc + 'weather-snow-large.svg')
elif icon_id == "50n":
img.set_from_icon_name('weather-fog-large')
img.set_from_file(icon_loc + 'weather-fog-large.svg')

return img

Expand All @@ -424,54 +434,54 @@ def forecast_icon(icon, size, frcst):
situa_img.set_pixel_size(size)

if icon == "01d":
situa_img.set_from_icon_name('weather-clear-large')
situa_img.set_from_file(icon_loc + 'weather-clear-large.svg')
css_class = "clear_sky"
elif icon == "02d" or icon == "03d":
situa_img.set_from_icon_name('weather-few-clouds-large')
situa_img.set_from_file(icon_loc + 'weather-few-clouds-large.svg')
css_class = 'few_clouds'
elif icon == "04d":
situa_img.set_from_icon_name('weather-overcast-large')
situa_img.set_from_file(icon_loc + 'weather-overcast-large.svg')
css_class = 'overcast'
elif icon == "09d":
situa_img.set_from_icon_name('weather-showers-scattered-large')
situa_img.set_from_file(icon_loc + 'weather-showers-scattered-large.svg')
css_class = 'showers_scattered'
elif icon == "10d":
situa_img.set_from_icon_name('weather-showers-large')
situa_img.set_from_icon_name(icon_loc + 'weather-showers-large.svg')
css_class = 'showers_large'
elif icon == "11d":
situa_img.set_from_icon_name('weather-storm-large')
situa_img.set_from_icon_name(icon_loc + 'weather-storm-large.svg')
css_class = 'storm'
elif icon == "13d":
situa_img.set_from_icon_name('weather-snow-large')
situa_img.set_from_icon_name(icon_loc + 'weather-snow-large.svg')
css_class = 'snow'
elif icon == "50d":
situa_img.set_from_icon_name('weather-fog-large')
situa_img.set_from_icon_name(icon_loc + 'weather-fog-large.svg')
css_class = 'fog'

# -------- night icons --------- #
elif icon == "01n":
situa_img.set_from_icon_name('weather-clear-night-large')
situa_img.set_from_icon_name(icon_loc + 'weather-clear-night-large.svg')
css_class = 'clear_sky_night'
elif icon == "02n" or icon == "03n":
situa_img.set_from_icon_name('weather-few-clouds-night-large')
situa_img.set_from_icon_name(icon_loc + 'weather-few-clouds-night-large.svg')
css_class = 'few_clouds_night'
elif icon == "04n":
situa_img.set_from_icon_name('weather-overcast-large')
situa_img.set_from_icon_name(icon_loc + 'weather-overcast-large.svg')
css_class = 'overcast_night'
elif icon == "09n":
situa_img.set_from_icon_name('weather-showers-scattered-large')
situa_img.set_from_icon_name(icon_loc + 'weather-showers-scattered-large.svg')
css_class = 'showers_scattered_night'
elif icon == "10n":
situa_img.set_from_icon_name('weather-showers-large')
situa_img.set_from_icon_name(icon_loc + 'weather-showers-large.svg')
css_class = 'showers_large_night'
elif icon == "11n":
situa_img.set_from_icon_name('weather-storm-large')
situa_img.set_from_icon_name(icon_loc + 'weather-storm-large.svg')
css_class = 'storm_night'
elif icon == "13n":
situa_img.set_from_icon_name('weather-snow-large')
situa_img.set_from_icon_name(icon_loc + 'weather-snow-large.svg')
css_class = 'snow_night'
elif icon == "50n":
situa_img.set_from_icon_name('weather-fog-large')
situa_img.set_from_icon_name(icon_loc + 'weather-fog-large.svg')
css_class = 'fog_night'


Expand Down Expand Up @@ -551,4 +561,4 @@ def convert_time(timezone):

local_full_time = str(converted_datetime) + ":" + datetime.now().strftime("%M")

return local_full_time
return local_full_time
Binary file modified Forecast/__pycache__/App.cpython-311.pyc
Binary file not shown.
Binary file modified Forecast/__pycache__/WttrInfo.cpython-311.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions data/dev.salaniLeo.forecast.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Name=Forecast
Exec=forecast
Icon=dev.salaniLeo.forecast
Keywords[en]=Weather;Forecast;Temperature;
Comment[en]=Forecast app for GNOME
Terminal=false
Type=Application
Categories=GTK;
Expand Down
1 change: 1 addition & 0 deletions data/status/info-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions data/status/temperature-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/status/weather-clear-large.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 29ee000

Please sign in to comment.