def on_calendar_month_changed(self, widget): """ Ask for days in this month, if they have logs it bolds them (marks them) """ if not self.jid: return year, month, _day = widget.get_date() # integers if year < 1900: widget.select_month(0, 1900) widget.select_day(1) return widget.clear_marks() month = python_month(month) try: log_days = app.logger.get_days_with_logs( self.account, self.jid, year, month) except exceptions.PysqliteOperationalError as error: ErrorDialog(_('Disk Error'), str(error)) return for date in log_days: widget.mark_day(date.day)
def on_calendar_day_selected(self, widget): if not self.jid: return year, month, day = self.calendar.get_date() # integers month = python_month(month) date_str = datetime.date(year, month, day).strftime('%x') self.date_label.set_text(date_str) self._load_conversation(year, month, day)
def on_calendar_day_selected(self, widget): if not self.jid: return year, month, day = self._ui.calendar.get_date() # integers month = python_month(month) date_str = datetime.date(year, month, day).strftime('%x') self._ui.date_label.set_text(date_str) self._load_conversation(year, month, day) GLib.idle_add(scroll_to_end, self._ui.scrolledwindow)
def _change_date(self, widget): # Get day selected in calendar y, m, d = self._ui.calendar.get_date() py_m = python_month(m) _date = datetime.datetime(y, py_m, d) if widget is self._ui.button_first_day: gtk_m = gtk_month(self.first_day.month) self._ui.calendar.select_month(gtk_m, self.first_day.year) self._ui.calendar.select_day(self.first_day.day) return if widget is self._ui.button_last_day: gtk_m = gtk_month( self.last_day.month) self._ui.calendar.select_month(gtk_m, self.last_day.year) self._ui.calendar.select_day(self.last_day.day) return if widget is self._ui.button_previous_day: end_date = self.first_day timedelta = datetime.timedelta(days=-1) if end_date >= _date: return elif widget is self._ui.button_next_day: end_date = self.last_day timedelta = datetime.timedelta(days=1) if end_date <= _date: return # Iterate through days until log entry found or # supplied end_date (first_log / last_log) reached logs = None while logs is None: _date = _date + timedelta if _date == end_date: break try: logs = app.logger.get_date_has_logs( self.account, self.jid, _date) except exceptions.PysqliteOperationalError as e: ErrorDialog(_('Disk Error'), str(e)) return gtk_m = gtk_month(_date.month) self._ui.calendar.select_month(gtk_m, _date.year) self._ui.calendar.select_day(_date.day)
def on_results_treeview_cursor_changed(self, *args): """ A row was selected, get date from row, and select it in calendar which results to showing conversation logs for that date """ if self.clearing_search: return # get currently selected date cur_year, cur_month, cur_day = self._ui.calendar.get_date() cur_month = python_month(cur_month) model, paths = self._ui.results_treeview.get_selection( ).get_selected_rows() if not paths: return path = paths[0] # make it a tuple (Y, M, D, 0, 0, 0...) tim = time.strptime(model[path][Column.UNIXTIME], '%Y-%m-%d') year = tim[0] gtk_m = tim[1] month = gtk_month(gtk_m) day = tim[2] # switch to belonging logfile if necessary log_jid = model[path][Column.LOG_JID] if log_jid != self.jid: self._load_history(log_jid, None) # avoid reruning mark days algo if same month and year! if year != cur_year or gtk_m != cur_month: self._ui.calendar.select_month(month, year) if year != cur_year or gtk_m != cur_month or day != cur_day: self._ui.calendar.select_day(day) self._scroll_to_message_and_highlight(model[path][Column.LOG_LINE_ID])
def on_search_entry_activate(self, widget): text = self._ui.search_entry.get_text() model = self._ui.results_treeview.get_model() self.clearing_search = True model.clear() self.clearing_search = False start = self.history_buffer.get_start_iter() end = self.history_buffer.get_end_iter() self.history_buffer.remove_tag_by_name('highlight', start, end) if text == '': self._ui.results_scrolledwindow.set_property('visible', False) return self._ui.results_scrolledwindow.set_property('visible', True) # perform search in preselected jids # jids are preselected with the query_entry for jid in self.jids_to_search: account = self.completion_dict[jid][InfoColumn.ACCOUNT] if account is None: # We do not know an account. This can only happen if # the contact is offine, or if we browse a groupchat history. # The account is not needed, a dummy can be set. # This may leed to wrong self nick in the displayed history account = list(app.contacts.get_accounts())[0] date = None if self._ui.search_in_date.get_active(): year, month, day = self._ui.calendar.get_date() # integers month = python_month(month) date = datetime.datetime(year, month, day) show_status = self._ui.show_status_checkbutton.get_active() results = app.logger.search_log(account, jid, text, date) result_found = False # FIXME: # add "subject: | message: " in message column if kind is single # also do we need show at all? (we do not search on subject) for row in results: if not show_status and row.kind in (KindConstant.GCSTATUS, KindConstant.STATUS): continue contact_name = row.contact_name if not contact_name: if row.kind == KindConstant.CHAT_MSG_SENT: contact_name = app.nicks[account] else: contact_name = self.completion_dict[jid][InfoColumn.NAME] local_time = time.localtime(row.time) date = time.strftime('%Y-%m-%d', local_time) result_found = True model.append((jid, contact_name, date, row.message, str(row.time), row.log_line_id)) if result_found: self._ui.results_treeview.set_cursor(0)