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 set_active(self): self.store.clear() configuration = Configuration() calendars_options = configuration.get('calendars') if os.path.exists(comun.TOKEN_FILE): if self.googlecalendar is not None: calendars = self.googlecalendar.calendars.values() else: gca = GoogleCalendar(token_file=comun.TOKEN_FILE) gca.read() calendars = gca.get_calendars().values() for calendar in calendars: calendar_options = get_calendar_from_options( configuration.get('calendars'), calendar['id']) if calendar_options: background_color = calendar_options['background'] foreground_color = calendar_options['foreground'] visible = calendar_options['visible'] if 'name' in calendar_options.keys(): calendar_name = calendar_options['name'] else: calendar_name = calendar['summary'] else: background_color = tohex() foreground_color = contraste(background_color) visible = True calendar_name = calendar['summary'] self.store.append([ calendar['summary'], background_color, foreground_color, calendar['id'], visible, calendar_name ])
def load_preferences(self): self.switch1.set_active(os.path.exists(comun.TOKEN_FILE)) configuration = Configuration() time = configuration.get('time') theme = configuration.get('theme') calendars_options = configuration.get('calendars') self.spin3.set_value(time) if os.path.exists( os.path.join( os.getenv("HOME"), ".config/autostart/calendar-indicator-autostart.desktop")): self.switch4.set_active(True) if theme == 'light': self.switch5.set_active(True) else: self.switch5.set_active(False) if os.path.exists(comun.TOKEN_FILE): if self.googlecalendar is not None: calendars = self.googlecalendar.calendars.values() else: gca = GoogleCalendar(token_file=comun.TOKEN_FILE) gca.read() calendars = gca.get_calendars().values() self.store.clear() for calendar in calendars: calendar_options = get_calendar_from_options( configuration.get('calendars'), calendar['id']) if calendar_options: background_color = calendar_options['background'] foreground_color = calendar_options['foreground'] visible = calendar_options['visible'] if 'name' in calendar_options.keys(): calendar_name = calendar_options['name'] else: calendar_name = calendar['summary'] else: background_color = tohex(random.randint(0, 16777215)) foreground_color = tohex(random.randint(0, 16777215)) visible = True calendar_name = calendar['summary'] self.store.append([ calendar['summary'], background_color, foreground_color, calendar['id'], visible, calendar_name ])
def load_preferences(self): self.switch1.set_active(os.path.exists(comun.TOKEN_FILE)) configuration = Configuration() time = configuration.get('time') theme = configuration.get('theme') calendars_options = configuration.get('calendars') self.spin3.set_value(time) if os.path.exists(os.path.join(os.getenv("HOME"),".config/autostart/calendar-indicator-autostart.desktop")): self.switch4.set_active(True) if theme == 'light': self.switch5.set_active(True) else: self.switch5.set_active(False) if os.path.exists(comun.TOKEN_FILE): if self.googlecalendar is not None: calendars = self.googlecalendar.calendars.values() else: gca = GoogleCalendar(token_file = comun.TOKEN_FILE) gca.read() calendars = gca.get_calendars().values() self.store.clear() for calendar in calendars: calendar_options = get_calendar_from_options(configuration.get('calendars'),calendar['id']) if calendar_options: background_color = calendar_options['background'] foreground_color = calendar_options['foreground'] visible = calendar_options['visible'] if 'name' in calendar_options.keys(): calendar_name = calendar_options['name'] else: calendar_name = calendar['summary'] else: background_color = tohex(random.randint(0, 16777215)) foreground_color = tohex(random.randint(0, 16777215)) visible = True calendar_name = calendar['summary'] self.store.append([calendar['summary'],background_color,foreground_color,calendar['id'],visible,calendar_name])
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'] ])