def on_buttonwwokey_clicked(self, widget):
     if len(self.wwokey.get_text()) > 0:
         wwo = WorldWeatherOnlineService(key=self.wwokey.get_text())
         if wwo.test_connection():
             self.radiobutton252.set_sensitive(True)
         else:
             self.radiobutton252.set_sensitive(False)
     else:
         self.radiobutton252.set_sensitive(False)
Example #2
0
 def on_buttonwwokey_clicked(self, widget):
     if len(self.wwokey.get_text()) > 0:
         wwo = WorldWeatherOnlineService(key=self.wwokey.get_text())
         if wwo.test_connection():
             self.radiobutton252.set_sensitive(True)
         else:
             self.radiobutton252.set_sensitive(False)
     else:
         self.radiobutton252.set_sensitive(False)
 def save_preferences(self):
     configuration = Configuration()
     if self.checkbutton11.get_active() and\
             (len(self.entry11.get_text()) == 0 or self.latitude is None or
              self.latitude == 0 or self.longitude is None or
              self.longitude == 0):
         self.latitude, self.longitude = ipaddress.get_current_location()
         ans = geocodeapi.get_inv_direction(self.latitude, self.longitude)
         if ans is not None and 'locality' in ans.keys():
             self.location = ans['locality']
     if self.checkbutton21.get_active() and\
             (len(self.entry21.get_text()) == 0 or
              self.latitude2 is None or self.latitude2 == 0 or
              self.longitude2 is None or self.longitude2 == 0):
         self.latitude2, self.longitude2 = ipaddress.get_current_location()
         ans = geocodeapi.get_inv_direction(self.latitude2, self.longitude2)
         if ans is not None and 'locality' in ans.keys():
             self.location2 = ans['locality']
     if len(self.entry11.get_text()) > 0:
         self.location = self.entry11.get_text()
     if len(self.entry21.get_text()) > 0:
         self.location2 = self.entry21.get_text()
     configuration.set('first-time', False)
     configuration.set('version', comun.VERSION)
     configuration.set('main-location', self.checkbutton11.get_active())
     configuration.set('autolocation', self.checkbutton10.get_active())
     configuration.set('location', self.location)
     configuration.set('latitude', self.latitude)
     configuration.set('longitude', self.longitude)
     configuration.set('show-temperature', self.checkbutton12.get_active())
     configuration.set('show-notifications',
                       self.checkbutton13.get_active())
     configuration.set('widget1', self.checkbutton14.get_active())
     configuration.set('onwidget1hide', self.checkbutton15.get_active())
     configuration.set('onwidget1top', self.checkbutton16.get_active())
     configuration.set('showintaskbar1', self.checkbutton17.get_active())
     configuration.set('onalldesktop1', self.checkbutton18.get_active())
     configuration.set('skin1',
                       get_selected_value_in_combo(self.comboboxskin1))
     #
     configuration.set('second-location', self.checkbutton21.get_active())
     configuration.set('location2', self.location2)
     configuration.set('latitude2', self.latitude2)
     configuration.set('longitude2', self.longitude2)
     configuration.set('show-temperature2', self.checkbutton22.get_active())
     configuration.set('show-notifications2',
                       self.checkbutton23.get_active())
     configuration.set('widget2', self.checkbutton24.get_active())
     configuration.set('onwidget2hide', self.checkbutton25.get_active())
     configuration.set('onwidget2top', self.checkbutton26.get_active())
     configuration.set('showintaskbar2', self.checkbutton27.get_active())
     configuration.set('onalldesktop2', self.checkbutton28.get_active())
     configuration.set('skin2',
                       get_selected_value_in_combo(self.comboboxskin2))
     #
     if self.radiobutton251.get_active():
         configuration.set('weather-service', 'yahoo')
     elif self.radiobutton253.get_active():
         configuration.set('weather-service', 'openweathermap')
     #
     wwokey = self.wwokey.get_text()
     if len(wwokey) > 0:
         wwo = WorldWeatherOnlineService(key=wwokey)
         if wwo.test_connection():
             configuration.set('wwo-key', wwokey)
             if self.radiobutton252.get_active():
                 configuration.set('weather-service', 'worldweatheronline')
         else:
             if self.radiobutton252.get_active():
                 configuration.set('weather-service', 'openweathermap')
     wukey = self.wukey.get_text()
     if len(wukey) > 0:
         wu = UndergroundWeatherService(key=wukey)
         if wu.test_connection():
             configuration.set('wu-key', wukey)
             if self.radiobutton254.get_active():
                 configuration.set('weather-service', 'wunderground')
         else:
             if self.radiobutton254.get_active():
                 configuration.set('weather-service', 'openweathermap')
     configuration.set(
         'temperature', get_selected_value_in_combo(self.combobox3))
     configuration.set(
         'pressure', get_selected_value_in_combo(self.combobox32))
     configuration.set(
         'visibility', get_selected_value_in_combo(self.combobox33))
     configuration.set(
         'wind', get_selected_value_in_combo(self.combobox31))
     configuration.set(
         'rain', get_selected_value_in_combo(self.combobox34))
     configuration.set(
         'snow', get_selected_value_in_combo(self.combobox35))
     configuration.set(
         '24h', get_selected_value_in_combo(self.combobox36))
     configuration.set(
         'refresh', get_selected_value_in_combo(self.combobox45))
     configuration.set('icon-light', self.radiobutton31.get_active())
     print('Saving...')
     configuration.save()
     #
     filestart = os.path.join(
         os.getenv("HOME"),
         ".config/autostart/my-weather-indicator-autostart.desktop")
     if self.checkbutton1.get_active():
         if not os.path.exists(os.path.dirname(filestart)):
             os.makedirs(os.path.dirname(filestart))
         shutil.copyfile(comun.AUTOSTART, filestart)
     else:
         if os.path.exists(filestart):
             os.remove(filestart)
 def load_preferences(self):
     configuration = Configuration()
     first_time = configuration.get('first-time')
     version = configuration.get('version')
     weatherservice = configuration.get('weather-service')
     if weatherservice == 'yahoo':
         self.radiobutton251.set_active(True)
     elif weatherservice == 'worldweatheronline':
         self.radiobutton252.set_active(True)
     elif weatherservice == 'openweathermap':
         self.radiobutton253.set_active(True)
     elif weatherservice == 'wunderground':
         self.radiobutton254.set_active(True)
     wwokey = configuration.get('wwo-key')
     if len(wwokey) > 0:
         self.wwokey.set_text(wwokey)
         wwo = WorldWeatherOnlineService(key=wwokey)
         if wwo.test_connection():
             self.radiobutton252.set_sensitive(True)
         else:
             if weatherservice == 'worldweatheronline':
                 self.radiobutton253.set_active(True)
     wukey = configuration.get('wu-key')
     if len(wukey) > 0:
         self.wukey.set_text(wukey)
         uws = UndergroundWeatherService(key=self.wukey.get_text())
         if uws.test_connection():
             self.radiobutton254.set_sensitive(True)
         else:
             if weatherservice == 'wunderground':
                 self.radiobutton253.set_active(True)
     #
     self.checkbutton11.set_active(configuration.get('main-location'))
     self.checkbutton10.set_active(configuration.get('autolocation'))
     self.location = configuration.get('location')
     self.latitude = configuration.get('latitude')
     self.longitude = configuration.get('longitude')
     if self.location:
         self.entry11.set_text(self.location)
     self.checkbutton12.set_active(configuration.get('show-temperature'))
     self.checkbutton13.set_active(configuration.get('show-notifications'))
     self.checkbutton14.set_active(configuration.get('widget1'))
     self.checkbutton15.set_active(configuration.get('onwidget1hide'))
     self.checkbutton15.set_sensitive(self.checkbutton14.get_active())
     self.checkbutton16.set_active(configuration.get('onwidget1top'))
     self.checkbutton16.set_sensitive(self.checkbutton14.get_active())
     self.checkbutton17.set_active(configuration.get('showintaskbar1'))
     self.checkbutton17.set_sensitive(self.checkbutton14.get_active())
     self.checkbutton18.set_active(configuration.get('onalldesktop1'))
     self.checkbutton18.set_sensitive(self.checkbutton14.get_active())
     select_value_in_combo(self.comboboxskin1, configuration.get('skin1'))
     self.comboboxskin1.set_sensitive(self.checkbutton14.get_active())
     #
     self.checkbutton21.set_active(configuration.get('second-location'))
     self.location2 = configuration.get('location2')
     self.latitude2 = configuration.get('latitude2')
     self.longitude2 = configuration.get('longitude2')
     if self.location2:
         self.entry21.set_text(self.location2)
     self.checkbutton22.set_active(configuration.get('show-temperature2'))
     self.checkbutton23.set_active(configuration.get('show-notifications2'))
     self.checkbutton24.set_active(configuration.get('widget2'))
     self.checkbutton25.set_active(configuration.get('onwidget2hide'))
     self.checkbutton25.set_sensitive(self.checkbutton24.get_active())
     self.checkbutton26.set_active(configuration.get('onwidget2top'))
     self.checkbutton26.set_sensitive(self.checkbutton24.get_active())
     self.checkbutton27.set_active(configuration.get('showintaskbar2'))
     self.checkbutton27.set_sensitive(self.checkbutton24.get_active())
     self.checkbutton28.set_active(configuration.get('onalldesktop2'))
     self.checkbutton28.set_sensitive(self.checkbutton24.get_active())
     select_value_in_combo(self.comboboxskin2, configuration.get('skin2'))
     self.comboboxskin2.set_sensitive(self.checkbutton24.get_active())
     #
     select_value_in_combo(self.combobox3, configuration.get('temperature'))
     select_value_in_combo(self.combobox32, configuration.get('pressure'))
     select_value_in_combo(self.combobox33, configuration.get('visibility'))
     select_value_in_combo(self.combobox31, configuration.get('wind'))
     select_value_in_combo(self.combobox34, configuration.get('rain'))
     select_value_in_combo(self.combobox35, configuration.get('snow'))
     select_value_in_combo(self.combobox36, configuration.get('24h'))
     select_value_in_combo(self.combobox45, configuration.get('refresh'))
     #
     self.radiobutton31.set_active(configuration.get('icon-light'))
     self.radiobutton32.set_active(not configuration.get('icon-light'))
Example #5
0
 def save_preferences(self):
     configuration = Configuration()
     if self.checkbutton11.get_active() and\
             (len(self.entry11.get_text()) == 0 or self.latitude is None or
              self.latitude == 0 or self.longitude is None or
              self.longitude == 0):
         self.latitude, self.longitude = ipaddress.get_current_location()
         ans = geocodeapi.get_inv_direction(self.latitude, self.longitude)
         if ans is not None and 'locality' in ans.keys():
             self.location = ans['locality']
     if self.checkbutton21.get_active() and\
             (len(self.entry21.get_text()) == 0 or
              self.latitude2 is None or self.latitude2 == 0 or
              self.longitude2 is None or self.longitude2 == 0):
         self.latitude2, self.longitude2 = ipaddress.get_current_location()
         ans = geocodeapi.get_inv_direction(self.latitude2, self.longitude2)
         if ans is not None and 'locality' in ans.keys():
             self.location2 = ans['locality']
     if len(self.entry11.get_text()) > 0:
         self.location = self.entry11.get_text()
     if len(self.entry21.get_text()) > 0:
         self.location2 = self.entry21.get_text()
     configuration.set('first-time', False)
     configuration.set('version', comun.VERSION)
     configuration.set('main-location', self.checkbutton11.get_active())
     configuration.set('autolocation', self.checkbutton10.get_active())
     configuration.set('location', self.location)
     configuration.set('latitude', self.latitude)
     configuration.set('longitude', self.longitude)
     configuration.set('show-temperature', self.checkbutton12.get_active())
     configuration.set('show-notifications',
                       self.checkbutton13.get_active())
     configuration.set('widget1', self.checkbutton14.get_active())
     configuration.set('onwidget1hide', self.checkbutton15.get_active())
     configuration.set('onwidget1top', self.checkbutton16.get_active())
     configuration.set('showintaskbar1', self.checkbutton17.get_active())
     configuration.set('onalldesktop1', self.checkbutton18.get_active())
     configuration.set('skin1',
                       get_selected_value_in_combo(self.comboboxskin1))
     #
     configuration.set('second-location', self.checkbutton21.get_active())
     configuration.set('location2', self.location2)
     configuration.set('latitude2', self.latitude2)
     configuration.set('longitude2', self.longitude2)
     configuration.set('show-temperature2', self.checkbutton22.get_active())
     configuration.set('show-notifications2',
                       self.checkbutton23.get_active())
     configuration.set('widget2', self.checkbutton24.get_active())
     configuration.set('onwidget2hide', self.checkbutton25.get_active())
     configuration.set('onwidget2top', self.checkbutton26.get_active())
     configuration.set('showintaskbar2', self.checkbutton27.get_active())
     configuration.set('onalldesktop2', self.checkbutton28.get_active())
     configuration.set('skin2',
                       get_selected_value_in_combo(self.comboboxskin2))
     #
     if self.radiobutton251.get_active():
         configuration.set('weather-service', 'yahoo')
     elif self.radiobutton253.get_active():
         configuration.set('weather-service', 'openweathermap')
     #
     wwokey = self.wwokey.get_text()
     if len(wwokey) > 0:
         wwo = WorldWeatherOnlineService(key=wwokey)
         if wwo.test_connection():
             configuration.set('wwo-key', wwokey)
             if self.radiobutton252.get_active():
                 configuration.set('weather-service', 'worldweatheronline')
         else:
             if self.radiobutton252.get_active():
                 configuration.set('weather-service', 'openweathermap')
     wukey = self.wukey.get_text()
     if len(wukey) > 0:
         wu = UndergroundWeatherService(key=wukey)
         if wu.test_connection():
             configuration.set('wu-key', wukey)
             if self.radiobutton254.get_active():
                 configuration.set('weather-service', 'wunderground')
         else:
             if self.radiobutton254.get_active():
                 configuration.set('weather-service', 'openweathermap')
     configuration.set(
         'temperature', get_selected_value_in_combo(self.combobox3))
     configuration.set(
         'pressure', get_selected_value_in_combo(self.combobox32))
     configuration.set(
         'visibility', get_selected_value_in_combo(self.combobox33))
     configuration.set(
         'wind', get_selected_value_in_combo(self.combobox31))
     configuration.set(
         'rain', get_selected_value_in_combo(self.combobox34))
     configuration.set(
         'snow', get_selected_value_in_combo(self.combobox35))
     configuration.set(
         '24h', get_selected_value_in_combo(self.combobox36))
     configuration.set(
         'refresh', get_selected_value_in_combo(self.combobox45))
     configuration.set('icon-light', self.radiobutton31.get_active())
     print('Saving...')
     configuration.save()
     #
     filestart = os.path.join(
         os.getenv("HOME"),
         ".config/autostart/my-weather-indicator-autostart.desktop")
     if self.checkbutton1.get_active():
         if not os.path.exists(os.path.dirname(filestart)):
             os.makedirs(os.path.dirname(filestart))
         shutil.copyfile(comun.AUTOSTART, filestart)
     else:
         if os.path.exists(filestart):
             os.remove(filestart)
Example #6
0
 def load_preferences(self):
     configuration = Configuration()
     first_time = configuration.get('first-time')
     version = configuration.get('version')
     weatherservice = configuration.get('weather-service')
     if weatherservice == 'yahoo':
         self.radiobutton251.set_active(True)
     elif weatherservice == 'worldweatheronline':
         self.radiobutton252.set_active(True)
     elif weatherservice == 'openweathermap':
         self.radiobutton253.set_active(True)
     elif weatherservice == 'wunderground':
         self.radiobutton254.set_active(True)
     wwokey = configuration.get('wwo-key')
     if len(wwokey) > 0:
         self.wwokey.set_text(wwokey)
         wwo = WorldWeatherOnlineService(key=wwokey)
         if wwo.test_connection():
             self.radiobutton252.set_sensitive(True)
         else:
             if weatherservice == 'worldweatheronline':
                 self.radiobutton253.set_active(True)
     wukey = configuration.get('wu-key')
     if len(wukey) > 0:
         self.wukey.set_text(wukey)
         uws = UndergroundWeatherService(key=self.wukey.get_text())
         if uws.test_connection():
             self.radiobutton254.set_sensitive(True)
         else:
             if weatherservice == 'wunderground':
                 self.radiobutton253.set_active(True)
     #
     self.checkbutton11.set_active(configuration.get('main-location'))
     self.checkbutton10.set_active(configuration.get('autolocation'))
     self.location = configuration.get('location')
     self.latitude = configuration.get('latitude')
     self.longitude = configuration.get('longitude')
     if self.location:
         self.entry11.set_text(self.location)
     self.checkbutton12.set_active(configuration.get('show-temperature'))
     self.checkbutton13.set_active(configuration.get('show-notifications'))
     self.checkbutton14.set_active(configuration.get('widget1'))
     self.checkbutton15.set_active(configuration.get('onwidget1hide'))
     self.checkbutton15.set_sensitive(self.checkbutton14.get_active())
     self.checkbutton16.set_active(configuration.get('onwidget1top'))
     self.checkbutton16.set_sensitive(self.checkbutton14.get_active())
     self.checkbutton17.set_active(configuration.get('showintaskbar1'))
     self.checkbutton17.set_sensitive(self.checkbutton14.get_active())
     self.checkbutton18.set_active(configuration.get('onalldesktop1'))
     self.checkbutton18.set_sensitive(self.checkbutton14.get_active())
     select_value_in_combo(self.comboboxskin1, configuration.get('skin1'))
     self.comboboxskin1.set_sensitive(self.checkbutton14.get_active())
     #
     self.checkbutton21.set_active(configuration.get('second-location'))
     self.location2 = configuration.get('location2')
     self.latitude2 = configuration.get('latitude2')
     self.longitude2 = configuration.get('longitude2')
     if self.location2:
         self.entry21.set_text(self.location2)
     self.checkbutton22.set_active(configuration.get('show-temperature2'))
     self.checkbutton23.set_active(configuration.get('show-notifications2'))
     self.checkbutton24.set_active(configuration.get('widget2'))
     self.checkbutton25.set_active(configuration.get('onwidget2hide'))
     self.checkbutton25.set_sensitive(self.checkbutton24.get_active())
     self.checkbutton26.set_active(configuration.get('onwidget2top'))
     self.checkbutton26.set_sensitive(self.checkbutton24.get_active())
     self.checkbutton27.set_active(configuration.get('showintaskbar2'))
     self.checkbutton27.set_sensitive(self.checkbutton24.get_active())
     self.checkbutton28.set_active(configuration.get('onalldesktop2'))
     self.checkbutton28.set_sensitive(self.checkbutton24.get_active())
     select_value_in_combo(self.comboboxskin2, configuration.get('skin2'))
     self.comboboxskin2.set_sensitive(self.checkbutton24.get_active())
     #
     select_value_in_combo(self.combobox3, configuration.get('temperature'))
     select_value_in_combo(self.combobox32, configuration.get('pressure'))
     select_value_in_combo(self.combobox33, configuration.get('visibility'))
     select_value_in_combo(self.combobox31, configuration.get('wind'))
     select_value_in_combo(self.combobox34, configuration.get('rain'))
     select_value_in_combo(self.combobox35, configuration.get('snow'))
     select_value_in_combo(self.combobox36, configuration.get('24h'))
     select_value_in_combo(self.combobox45, configuration.get('refresh'))
     #
     self.radiobutton31.set_active(configuration.get('icon-light'))
     self.radiobutton32.set_active(not configuration.get('icon-light'))