Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RingOV committed Jul 4, 2019
1 parent e9711f6 commit 2d605bb
Show file tree
Hide file tree
Showing 14 changed files with 282 additions and 214 deletions.
13 changes: 9 additions & 4 deletions dialogs/city_id_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def set_service(widget, label, liststore2, combobox_weather_lang, weather_lang,
gw_config['city_id'] = gw_config[data.get_city_list(i)][0].split(';')[0]
except:
pass
gw_config['max_days'] = data.get_max_days(i)
gw_config['max_days'] = data.get(i)['max_days']
if gw_config['n'] > gw_config['max_days']:
gw_config['n'] = gw_config['max_days']
if data.get_need_appid(i):
if data.get(i)['need_appid']:
grid_appid.show()
else:
grid_appid.hide()
Expand All @@ -69,7 +69,12 @@ def set_weather_lang(widget):
def load_data(service, label, liststore2, combobox_weather_lang, weather_lang, store):
global url, example, code, dict_weather_lang, weather_lang_list, gw_config, loading
loading = True
url, example, code, dict_weather_lang, weather_lang_list = data.get(service)
d = data.get(service)
url = d['url']
example = d['example']
code = d['code']
dict_weather_lang = d['dict_weather_lang']
weather_lang_list = d['weather_lang_list']
text = _("Choose your city on")+" <a href='%s'>%s</a>\n" %(url, url)+\
_("and copy the city code below")+"\n"+\
_("For example")+ ":\n<u><span foreground='blue'>%s/</span></u>\n" %example+\
Expand All @@ -95,7 +100,7 @@ def load_data(service, label, liststore2, combobox_weather_lang, weather_lang, s
store.clear()
for item in city_list:
store.append([item.split(';')[0], item.split(';')[1]])
if data.get_need_appid(service):
if data.get(service)['need_appid']:
grid_appid.show()
try: entrybox_appid.set_text(gw_config[data.get_appid(service)])
except: entrybox_appid.set_text('')
Expand Down
16 changes: 9 additions & 7 deletions dialogs/settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def __init__(self):
self.spinbutton_scale.connect("value-changed", self.save_settings)
self.switch_always_on_top = self.ui.get_object('switch_always_on_top')
self.switch_always_on_top.connect("notify::active", self.save_settings)
self.spinbutton_height_tune = self.ui.get_object('spinbutton_height_tune')
self.spinbutton_height_tune.connect("value-changed", self.save_settings)
self.spinbutton_height_adjustment = self.ui.get_object('spinbutton_height_adjustment')
self.spinbutton_height_adjustment.connect("value-changed", self.save_settings)


self.clear_x_pos = self.ui.get_object('clear_x_pos')
Expand All @@ -217,8 +217,8 @@ def __init__(self):
self.clear_scale.connect("clicked", self.clear_settings)
self.clear_always_on_top = self.ui.get_object('clear_always_on_top')
self.clear_always_on_top.connect("clicked", self.clear_settings)
self.clear_height_tune = self.ui.get_object('clear_height_tune')
self.clear_height_tune.connect("clicked", self.clear_settings)
self.clear_height_adjustment = self.ui.get_object('clear_height_adjustment')
self.clear_height_adjustment.connect("clicked", self.clear_settings)

# View

Expand Down Expand Up @@ -546,7 +546,7 @@ def load_config_into_form(self):
self.load(self.switch_block_sunrise__show)
self.load(self.switch_block_moonrise__show)
self.load(self.switch_always_on_top)
self.load(self.spinbutton_height_tune)
self.load(self.spinbutton_height_adjustment)

self.adjustment_n_max.set_upper(gw_config_set['max_days'])

Expand Down Expand Up @@ -854,7 +854,7 @@ def set_service(self, widget):
gw_config_set['city_id'] = city_list[0].split(';')[0]
else:
gw_config_set['city_id'] = 0
gw_config_set['max_days'] = data.get_max_days(gw_config_set['service'])
gw_config_set['max_days'] = data.get(gw_config_set['service'])['max_days']
if gw_config_set['n'] > gw_config_set['max_days']:
gw_config_set['n'] = gw_config_set['max_days']
self.spinbutton_n.set_value(gw_config_set['n'])
Expand All @@ -865,7 +865,9 @@ def set_service(self, widget):

def load_available_service_lang(self, service):
global dict_weather_lang, weather_lang_list
url, example, code, dict_weather_lang, weather_lang_list = data.get(gw_config_set['service'])
d = data.get(gw_config_set['service'])
dict_weather_lang = d['dict_weather_lang']
weather_lang_list = d['weather_lang_list']
self.liststore6.clear()
for i in range(len(weather_lang_list)):
try:
Expand Down
6 changes: 3 additions & 3 deletions dialogs/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Height tune</property>
<property name="label" translatable="yes">Height adjustment</property>
<property name="xalign">0</property>
</object>
<packing>
Expand All @@ -1893,7 +1893,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="clear_height_tune">
<object class="GtkButton" id="clear_height_adjustment">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
Expand All @@ -1907,7 +1907,7 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_height_tune">
<object class="GtkSpinButton" id="spinbutton_height_adjustment">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
Expand Down
21 changes: 12 additions & 9 deletions gis-weather.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
#
# gis_weather.py
v = '0.8.3.11'
v = '0.8.3.12'
# Copyright (C) 2013-2019 Alexander Koltsov <ringov@mail.ru>
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -203,7 +203,7 @@ def make_dirs(path):
'block_icons_top': 0,
'day_left': 0,
'day_top': 0,
'height_tune': 0,
'height_adjustment': 0,
'width_fix': 0, #FIXME Not used
'splash_icon_top': 0,
'splash_version_top': 0,
Expand Down Expand Up @@ -452,7 +452,7 @@ def get_weather():
service = data.services_list[0]
weather_lang = data.get(service)[-1][0]
Save_Config()
if city_id == 0 or (not appid and data.get_need_appid(service)):
if city_id == 0 or (not appid and data.get(service)['need_appid']):
if app.show_edit_dialog():
Save_Config()
if city_id == 0:
Expand Down Expand Up @@ -994,7 +994,7 @@ def Draw_Weather(self, cr):

for i in range(1, n+1):
try:
self.draw_weather_icon(cr, i, -8+block_icons_left + margin + block_margin + (i-1)*w_block + (i-1)*block_h_offset, block_icons_top + height-h_block-10 - margin - height_tune)
self.draw_weather_icon(cr, i, -8+block_icons_left + margin + block_margin + (i-1)*w_block + (i-1)*block_h_offset, block_icons_top + height-h_block-10 - margin - height_adjustment)
except:
print('Can\'t show weather for %s day'%str(i))

Expand Down Expand Up @@ -1584,7 +1584,7 @@ def set_window_properties(self):
if n < 1: n = 1
# width = w_block*n + block_margin*2 + 10*(n - 1) + 2*margin + block_icons_left
width = w_block*n + block_h_offset*n + 2*margin + block_icons_left + width_fix
height = 260 + block_margin + 2*margin + height_tune
height = 260 + block_margin + 2*margin + height_adjustment
self.window_main.resize(int(width*scale), int(height*scale))
self.window_main.move(x_pos, y_pos)
if sticky:
Expand Down Expand Up @@ -1620,12 +1620,15 @@ def menu_response(self, widget, event, value=None):
weather_menu = True
Save_Config()
if event == 'goto_site':
print(URL)
if URL:
webbrowser.open(URL)
if event == 'goto_site_hourly':
print(URL_HOURLY)
if URL_HOURLY != '?':
webbrowser.open(URL_HOURLY)
if event == 'goto_site_day':
print(URL_DAILY)
if URL_DAILY != '?':
webbrowser.open(URL_DAILY+str(value))
if event == 'start_new_instance':
Expand Down Expand Up @@ -1745,8 +1748,8 @@ def menu_response(self, widget, event, value=None):
if value[1] != 0:
service = value[0]
city_id = value[1].split(';')[0]
max_days = data.get_max_days(service)
if data.get_need_appid(service):
max_days = data.get(service)['max_days']
if data.get(service)['need_appid']:
appid = gw_config[data.get_appid(service)]
if service+'_weather_lang' in gw_config.keys():
weather_lang = gw_config[service+'_weather_lang']
Expand Down Expand Up @@ -1809,7 +1812,7 @@ def show_edit_dialog(self):
pass
if response == Gtk.ResponseType.OK:
try:
if data.get_need_appid(service) and entrybox_appid.get_text() != '':
if data.get(service)['need_appid'] and entrybox_appid.get_text() != '':
appid = entrybox_appid.get_text()
gw_config[data.get_appid(service)] = appid
Save_Config()
Expand Down Expand Up @@ -1852,7 +1855,7 @@ def show_edit_dialog(self):
city_id = city_list[0].split(';')[0]
else:
city_id = 0
if data.get_need_appid(service) and entrybox_appid.get_text() != '':
if data.get(service)['need_appid'] and entrybox_appid.get_text() != '':
appid = entrybox_appid.get_text()
gw_config[data.get_appid(service)] = appid
Save_Config()
Expand Down
Binary file modified i18n/fr/LC_MESSAGES/gis-weather.mo
Binary file not shown.
Binary file modified i18n/pt_BR/LC_MESSAGES/gis-weather.mo
Binary file not shown.
Loading

0 comments on commit 2d605bb

Please sign in to comment.