def on_switch1_changed(self,widget,data): if self.switch1.get_active(): if os.path.exists(comun.TOKEN_FILE): os.remove(comun.TOKEN_FILE) else: googlecalendar = GoogleCalendar(token_file = comun.TOKEN_FILE) if googlecalendar.do_refresh_authorization() is None: authorize_url = googlecalendar.get_authorize_url() ld = LoginDialog(authorize_url) ld.run() googlecalendar.get_authorization(ld.code) ld.destroy() if googlecalendar.do_refresh_authorization() is None: md = Gtk.MessageDialog( parent = self, flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, type = Gtk.MessageType.ERROR, buttons = Gtk.ButtonsType.OK_CANCEL, message_format = _('You have to authorize Calendar-Indicator to use it, do you want to authorize?')) if md.run() == Gtk.ResponseType.CANCEL: exit(3) else: if googlecalendar.do_refresh_authorization() is None: exit(3) self.switch1.set_active(True) self.store.clear() for calendar in googlecalendar.get_calendars().values(): self.store.append([calendar['summary'],tohex(random.randint(0, 16777215)),tohex(random.randint(0, 16777215)),calendar['id'],True,calendar['summary']])
def on_switch1_changed(self, widget, data): if self.switch1.get_active(): if os.path.exists(comun.TOKEN_FILE): os.remove(comun.TOKEN_FILE) else: googlecalendar = GoogleCalendar(token_file=comun.TOKEN_FILE) if googlecalendar.do_refresh_authorization() is None: authorize_url = googlecalendar.get_authorize_url() ld = LoginDialog(authorize_url) ld.run() googlecalendar.get_authorization(ld.code) ld.destroy() if googlecalendar.do_refresh_authorization() is None: md = Gtk.MessageDialog( parent=self, flags=Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK_CANCEL, message_format= _('You have to authorize Calendar-Indicator to use it, do you want to authorize?' )) if md.run() == Gtk.ResponseType.CANCEL: exit(3) else: if googlecalendar.do_refresh_authorization() is None: exit(3) self.switch1.set_active(True) self.store.clear() for calendar in googlecalendar.get_calendars().values(): self.store.append([ calendar['summary'], tohex(random.randint(0, 16777215)), tohex(random.randint(0, 16777215)), calendar['id'], True, calendar['summary'] ])