~kobe24-lixiang/indicator-china-weather/trunk-1

« back to all changes in this revision

Viewing changes to src/indicator-china-weather.py

  • Committer: kobe
  • Date: 2014-02-11 07:10:53 UTC
  • Revision ID: xiangli@ubuntukylin.com-20140211071053-7bwfx3n8x3d6bpgt
Avoid adding the same city

Show diffs side-by-side

added added

removed removed

Lines of Context:
543
543
            self.aboutdialog = gtk.AboutDialog()
544
544
            self.aboutdialog.set_name(_("Indicator China Weather"))
545
545
            self.aboutdialog.set_version(VERSION)
546
 
            self.aboutdialog.set_copyright('Copyright (C) 2013 UbuntuKylin Team kobe24_lixiang@126.com')
 
546
            self.aboutdialog.set_copyright('Copyright (C) 2014 UbuntuKylin Team kobe24_lixiang@126.com')
547
547
 
548
548
            self.aboutdialog.set_comments(_('天气插件:提供来自于中国气象局的六天天气预报信息,添加\n人们日益关注的PM2.5指数,支持多城市切换和数据自动更新,\n分享每日生活指数和建议,为用户日常起居和旅行提供参考。'))
549
549
 
782
782
        else:
783
783
            iw.city_change_flag = False
784
784
        iw.city_id = self.cityid
785
 
        iw.place = [self.cityid,self.context]
786
 
        iw.settings.set_value("city_id", self.cityid)
787
785
 
788
 
        if iw.places not in (False, None, '', '[]', "['']") and iw.place in iw.places and iw.prefswindow.builder.get_object('citieslist').get_iter_first() != None:
789
 
            iw.placechosen = iw.places.index(iw.place)
 
786
        # --------added 20140211 by kobe--------
 
787
        flag = False
 
788
        for placeitem in iw.places:
 
789
            if placeitem[0] == iw.city_id:
 
790
                flag = True
 
791
                break
 
792
        if flag:
 
793
            flag = False
790
794
        else:
791
 
            newplace = list()
792
 
            newplace.append(self.context)#Label
793
 
            newplace.append(self.cityid)#City
794
 
            newplace.append(self.cityid)#details
795
 
            item = iw.prefswindow.builder.get_object('citieslist').get_iter_first()
796
 
            iw.prefswindow.builder.get_object('citieslist').append(newplace)
 
795
            iw.place = [self.cityid,self.context]
 
796
            iw.settings.set_value("city_id", self.cityid)
 
797
            if iw.places not in (False, None, '', '[]', "['']") and iw.place in iw.places and iw.prefswindow.builder.get_object('citieslist').get_iter_first() != None:
 
798
                iw.placechosen = iw.places.index(iw.place)
 
799
            else:
 
800
                newplace = list()
 
801
                newplace.append(self.context)#Label
 
802
                newplace.append(self.cityid)#City
 
803
                newplace.append(self.cityid)#details
 
804
                item = iw.prefswindow.builder.get_object('citieslist').get_iter_first()
 
805
                iw.prefswindow.builder.get_object('citieslist').append(newplace)
797
806
 
798
807
        # Enable 'OK' button in Preferences
799
808
        iw.prefswindow.builder.get_object('ok_button').set_sensitive(True)