Ejemplo n.º 1
0
    def on_results_treeview_row_activated(self, widget, path, column):
        """
        A row was double clicked, get date from row, and select it in calendar
        which results to showing conversation logs for that date
        """
        # get currently selected date
        cur_year, cur_month = self.calendar.get_date()[0:2]
        cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
        model = widget.get_model()
        # make it a tupple (Y, M, D, 0, 0, 0...)
        tim = time.strptime(model[path][Column.UNIXTIME], '%Y-%m-%d')
        year = tim[0]
        gtk_month = tim[1]
        month = gtkgui_helpers.make_python_month_gtk_month(gtk_month)
        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_month != cur_month:
            self.calendar.select_month(month, year)

        self.calendar.select_day(day)
        unix_time = model[path][Column.TIME]
        self._scroll_to_result(unix_time)
Ejemplo n.º 2
0
    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

        # in gtk January is 1, in python January is 0,
        # I want the second
        # first day of month is 1 not 0
        widget.clear_marks()
        month = gtkgui_helpers.make_gtk_month_python_month(month)
        days_in_this_month = calendar.monthrange(year, month)[1]
        try:
            log_days = gajim.logger.get_days_with_logs(self.jid, year, month,
                                                       days_in_this_month,
                                                       self.account)
        except exceptions.PysqliteOperationalError as e:
            dialogs.ErrorDialog(_('Disk Error'), str(e))
            return
        for day in log_days:
            widget.mark_day(day)
Ejemplo n.º 3
0
    def on_results_treeview_row_activated(self, widget, path, column):
        """
        A row was double clicked, get date from row, and select it in calendar
        which results to showing conversation logs for that date
        """
        # get currently selected date
        cur_year, cur_month = self.calendar.get_date()[0:2]
        cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
        model = widget.get_model()
        # make it a tupple (Y, M, D, 0, 0, 0...)
        tim = time.strptime(model[path][C_UNIXTIME], '%Y-%m-%d')
        year = tim[0]
        gtk_month = tim[1]
        month = gtkgui_helpers.make_python_month_gtk_month(gtk_month)
        day = tim[2]

        # switch to belonging logfile if necessary
        log_jid = model[path][C_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_month != cur_month:
            self.calendar.select_month(month, year)

        self.calendar.select_day(day)
        unix_time = model[path][C_TIME]
        self._scroll_to_result(unix_time)
Ejemplo n.º 4
0
    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

        # in gtk January is 1, in python January is 0,
        # I want the second
        # first day of month is 1 not 0
        widget.clear_marks()
        month = gtkgui_helpers.make_gtk_month_python_month(month)
        days_in_this_month = calendar.monthrange(year, month)[1]
        try:
            log_days = gajim.logger.get_days_with_logs(self.jid, year, month,
                days_in_this_month, self.account)
        except exceptions.PysqliteOperationalError as e:
            dialogs.ErrorDialog(_('Disk Error'), str(e))
            return
        for day in log_days:
            widget.mark_day(day)
Ejemplo n.º 5
0
    def on_search_entry_activate(self, widget):
        text = self.search_entry.get_text()
        model = self.results_treeview.get_model()
        model.clear()
        if text == '':
            self.results_window.set_property('visible', False)
            return
        else:
            self.results_window.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 (Uggh!)
                account = list(gajim.contacts.get_accounts())[0]

            year, month, day = False, False, False
            if self.search_in_date.get_active():
                year, month, day = self.calendar.get_date()  # integers
                month = gtkgui_helpers.make_gtk_month_python_month(month)

            show_status = self.show_status_checkbutton.get_active()

            # contact_name, time, kind, show, message, subject
            results = gajim.logger.get_search_results_for_query(
                jid, text, account, year, month, day)
            #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[2] in (KindConstant.GCSTATUS,
                                                  KindConstant.STATUS):
                    continue
                contact_name = row[0]
                if not contact_name:
                    kind = row[2]
                    if kind == KindConstant.CHAT_MSG_SENT:  # it's us! :)
                        contact_name = gajim.nicks[account]
                    else:
                        contact_name = self.completion_dict[jid][
                            InfoColumn.NAME]
                tim = row[1]
                message = row[4]
                local_time = time.localtime(tim)
                date = time.strftime('%Y-%m-%d', local_time)

                #  jid (to which log is assigned to), name, date, message,
                # time (full unix time)
                model.append((jid, contact_name, date, message, str(tim)))
Ejemplo n.º 6
0
    def on_query_entry_activate(self, widget):
        text = self.query_entry.get_text()
        model = self.results_treeview.get_model()
        model.clear()
        if text == '':
            self.results_window.set_property('visible', False)
            return
        else:
            self.results_window.set_property('visible', True)

        # perform search in preselected jids
        # jids are preselected with the query_combobox (all, single jid...)
        for jid in self.jids_to_search:
            account = self.completion_dict[jid][C_INFO_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
                # (Uggh!)
                account = gajim.contacts.get_accounts()[0]

            year, month, day = False, False, False
            if self.search_in_date.get_active():
                year, month, day = self.calendar.get_date() # integers
                month = gtkgui_helpers.make_gtk_month_python_month(month)

            show_status = self.show_status_checkbutton.get_active()

            # contact_name, time, kind, show, message, subject
            results = gajim.logger.get_search_results_for_query(jid, text,
                account, year, month, day)
            #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[2] in (constants.KIND_GCSTATUS,
                constants.KIND_STATUS):
                    continue
                contact_name = row[0]
                if not contact_name:
                    kind = row[2]
                    if kind == constants.KIND_CHAT_MSG_SENT: # it's us! :)
                        contact_name = gajim.nicks[account]
                    else:
                        contact_name = self.completion_dict[jid][C_INFO_NAME]
                tim = row[1]
                message = row[4]
                local_time = time.localtime(tim)
                date = time.strftime('%Y-%m-%d', local_time)

                #  jid (to which log is assigned to), name, date, message,
                # time (full unix time)
                model.append((jid, contact_name, date, message, tim))
Ejemplo n.º 7
0
	def on_calendar_month_changed(self, widget):
		year, month, day = widget.get_date() # integers
		# in gtk January is 1, in python January is 0,
		# I want the second
		# first day of month is 1 not 0
		if self.mark_days_idle_call_id:
			# if user changed month, and we have a generator filling mark days
			# stop him from marking dates for the previously selected month
			gobject.source_remove(self.mark_days_idle_call_id)
		widget.clear_marks()
		month = gtkgui_helpers.make_gtk_month_python_month(month)
		self.mark_days_idle_call_id = gobject.idle_add(
			self.do_possible_mark_for_days_in_this_month(widget, year, month).next)
Ejemplo n.º 8
0
	def on_calendar_month_changed(self, widget):
		'''asks 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
		# in gtk January is 1, in python January is 0,
		# I want the second
		# first day of month is 1 not 0
		widget.clear_marks()
		month = gtkgui_helpers.make_gtk_month_python_month(month)
		weekday, days_in_this_month = calendar.monthrange(year, month)
		log_days = gajim.logger.get_days_with_logs(self.jid, year,
			month, days_in_this_month, self.account)
		for day in log_days:
			widget.mark_day(day)
Ejemplo n.º 9
0
	def on_results_treeview_row_activated(self, widget, path, column):
		'''a row was double clicked, get date from row, and select it in calendar
		which results to showing conversation logs for that date'''
		# get currently selected date
		cur_year, cur_month, cur_day = self.calendar.get_date()
		cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
		model = widget.get_model()
		iter = model.get_iter(path)
		# make it (Y, M, D, ...)
		tim = time.strptime(model[iter][C_TIME], '%Y-%m-%d %H:%M:%S')
		year = tim[0]
		gtk_month = tim[1]
		month = gtkgui_helpers.make_python_month_gtk_month(gtk_month)
		day = tim[2]
		
		# avoid reruning mark days algo if same month and year!
		if year != cur_year or gtk_month != cur_month:
			self.calendar.select_month(month, year)
		
		self.calendar.select_day(day)
Ejemplo n.º 10
0
 def on_calendar_day_selected(self, widget):
     if not self.jid:
         return
     year, month, day = self.calendar.get_date()  # integers
     month = gtkgui_helpers.make_gtk_month_python_month(month)
     self._add_lines_for_date(year, month, day)
Ejemplo n.º 11
0
	def on_calendar_day_selected(self, widget):
		year, month, day = widget.get_date() # integers
		month = gtkgui_helpers.make_gtk_month_python_month(month)
		self.add_lines_for_date(year, month, day)
Ejemplo n.º 12
0
 def on_calendar_day_selected(self, widget):
     if not self.jid:
         return
     year, month, day = self.calendar.get_date() # integers
     month = gtkgui_helpers.make_gtk_month_python_month(month)
     self._add_lines_for_date(year, month, day)