def set_img(self, *args): """ Apart from image, we also update tooltip text here """ if not app.interface.systray_enabled: return if app.config.get('trayicon') == 'always': self.status_icon.set_visible(True) if app.events.get_nb_systray_events(): self.status_icon.set_visible(True) icon_name = gtkgui_helpers.get_iconset_name_for('event') self.status_icon.set_from_icon_name(icon_name) return else: if app.config.get('trayicon') == 'on_event': self.status_icon.set_visible(False) icon_name = gtkgui_helpers.get_iconset_name_for(self.status) self.status_icon.set_from_icon_name(icon_name)
def _get_icon_name(self, obj): if obj.notif_type == 'msg': if obj.base_event.mtype == 'pm': return 'gajim-priv_msg_recv' if obj.base_event.mtype == 'normal': return 'gajim-single_msg_recv' elif obj.notif_type == 'pres': if obj.transport_name is not None: return '%s-%s' % (obj.transport_name, obj.show) else: return gtkgui_helpers.get_iconset_name_for(obj.show)
def _fill_completion_dict(self): """ Fill completion_dict for key auto completion. Then load history for current jid (by calling another function) Key will be either jid or full_completion_name (contact name or long description like "pm-contact from groupchat...."). {key : (jid, account, nick_name, full_completion_name} This is a generator and does pseudo-threading via idle_add(). """ liststore = gtkgui_helpers.get_completion_liststore(self.jid_entry) # Add all jids in logs.db: db_jids = app.logger.get_jids_in_db() completion_dict = dict.fromkeys(db_jids) self.accounts_seen_online = list(app.contacts.get_accounts()) # Enhance contacts of online accounts with contact. Needed for mapping below for account in self.accounts_seen_online: completion_dict.update( helpers.get_contact_dict_for_account(account)) muc_active_icon = gtkgui_helpers.get_iconset_name_for('muc-active') online_icon = gtkgui_helpers.get_iconset_name_for('online') keys = list(completion_dict.keys()) # Move the actual jid at first so we load history faster actual_jid = self.jid_entry.get_text() if actual_jid in keys: keys.remove(actual_jid) keys.insert(0, actual_jid) if '' in keys: keys.remove('') if None in keys: keys.remove(None) # Map jid to info tuple # Warning : This for is time critical with big DB for key in keys: completed = key completed2 = None contact = completion_dict[completed] if contact: info_name = contact.get_shown_name() info_completion = info_name info_jid = contact.jid else: # Corrensponding account is offline, we know nothing info_name = completed.split('@')[0] info_completion = completed info_jid = completed info_acc = self._get_account_for_jid(info_jid) if app.logger.jid_is_room_jid(completed) or\ app.logger.jid_is_from_pm(completed): icon = muc_active_icon if app.logger.jid_is_from_pm(completed): # It's PM. Make it easier to find room, nick = app.get_room_and_nick_from_fjid(completed) info_completion = '%s from %s' % (nick, room) completed = info_completion info_completion2 = '%s/%s' % (room, nick) completed2 = info_completion2 info_name = nick else: icon = online_icon if len(completed) > 70: completed = completed[:70] + '[\u2026]' liststore.append((icon, completed)) self.completion_dict[key] = (info_jid, info_acc, info_name, info_completion) self.completion_dict[completed] = (info_jid, info_acc, info_name, info_completion) if completed2: if len(completed2) > 70: completed2 = completed2[:70] + '[\u2026]' liststore.append((icon, completed2)) self.completion_dict[completed2] = (info_jid, info_acc, info_name, info_completion2) if key == actual_jid: self._load_history(info_jid, self.account or info_acc) yield True keys.sort() yield False
def _update_image(self): show = helpers.get_current_show(self.account) icon = gtkgui_helpers.get_iconset_name_for(show) self.image.set_from_icon_name(icon, Gtk.IconSize.MENU)