Esempio n. 1
0
    def set_os_info(self, result, jid):
        if self.xml.get_object('information_notebook').get_n_pages() < 5:
            return

        error = is_error_result(result)
        i = 0
        client = ''
        os_info = ''
        while i in self.os_info:
            if self.os_info[i]['resource'] == JID(jid).getResource():
                if not error:
                    self.os_info[i]['client'] = '%s %s' % (result.name,
                                                           result.version)
                else:
                    self.os_info[i]['client'] = Q_('?Client:Unknown')

                if not error and result.os is not None:
                    self.os_info[i]['os'] = result.os
                else:
                    self.os_info[i]['os'] = Q_('?OS:Unknown')

            if i > 0:
                client += '\n'
                os_info += '\n'
            client += self.os_info[i]['client']
            os_info += self.os_info[i]['os']
            i += 1

        self.xml.get_object('client_name_version_label').set_text(client)
        self.xml.get_object('os_label').set_text(os_info)
        self.os_info_arrived = True
Esempio n. 2
0
    def set_entity_time(self, obj):
        if obj.conn.name != self.account:
            return
        if self.xml.get_object('information_notebook').get_n_pages() < 5:
            return
        if self.gc_contact:
            if obj.jid != self.contact.jid:
                return
        elif obj.jid.getStripped() != self.contact.jid:
            return
        i = 0
        time_s = ''
        while i in self.time_info:
            if self.time_info[i]['resource'] == obj.jid.getResource():
                if obj.time_info:
                    self.time_info[i]['time'] = obj.time_info
                else:
                    self.time_info[i]['time'] = Q_('?Time:Unknown')
            else:
                if not self.time_info[i]['time']:
                    self.time_info[i]['time'] = Q_('?Time:Unknown')
            if i > 0:
                time_s += '\n'
            time_s += self.time_info[i]['time']
            i += 1

        self.xml.get_object('time_label').set_text(time_s)
        self.entity_time_arrived = True
Esempio n. 3
0
    def _create_tooltip(self, file_props, _sid):
        ft_grid = Gtk.Grid.new()
        ft_grid.insert_column(0)
        ft_grid.set_row_spacing(6)
        ft_grid.set_column_spacing(12)
        current_row = 0
        properties = []
        name = file_props.name
        if file_props.type_ == 'r':
            file_name = os.path.split(file_props.file_name)[1]
        else:
            file_name = file_props.name
        properties.append((_('File Name: '),
                           GLib.markup_escape_text(file_name)))
        if file_props.type_ == 'r':
            type_ = Q_('?Noun:Download')
            actor = _('Sender: ')
            sender = file_props.sender.split('/')[0]
            name = app.contacts.get_first_contact_from_jid(
                file_props.tt_account, sender).get_shown_name()
        else:
            type_ = Q_('?Noun:Upload')
            actor = _('Recipient: ')
            receiver = file_props.receiver
            if hasattr(receiver, 'name'):
                name = receiver.get_shown_name()
            else:
                name = receiver.split('/')[0]
        properties.append((Q_('?transfer type:Type: '), type_))
        properties.append((actor, GLib.markup_escape_text(name)))

        transfered_len = file_props.received_len
        if not transfered_len:
            transfered_len = 0
        properties.append((Q_('?transfer status:Transferred: '),
                           GLib.format_size_full(transfered_len, self.units)))
        status = self._get_current_status(file_props)
        properties.append((Q_('?transfer status:Status: '), status))
        file_desc = file_props.desc or ''
        properties.append((_('Description: '),
                           GLib.markup_escape_text(file_desc)))

        while properties:
            property_ = properties.pop(0)
            label = Gtk.Label()
            label.set_halign(Gtk.Align.END)
            label.set_valign(Gtk.Align.CENTER)
            label.set_markup(property_[0])
            ft_grid.attach(label, 0, current_row, 1, 1)
            label = Gtk.Label()
            label.set_halign(Gtk.Align.START)
            label.set_valign(Gtk.Align.START)
            label.set_line_wrap(True)
            label.set_markup(property_[1])
            ft_grid.attach(label, 1, current_row, 1, 1)
            current_row += 1

        ft_grid.show_all()
        return ft_grid
Esempio n. 4
0
    def __init__(self):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_show_menubar(False)
        self.set_name('AdvancedConfig')
        self.set_title(_('Advanced Configuration Editor (ACE)'))

        self._ui = get_builder('advanced_configuration.ui')
        self.add(self._ui.box)

        treeview = self._ui.advanced_treeview
        self.treeview = treeview
        self.model = Gtk.TreeStore(str, str, str)
        self._fill_model()
        self.model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self.modelfilter = self.model.filter_new()
        self.modelfilter.set_visible_func(self._visible_func)

        renderer_text = Gtk.CellRendererText()
        renderer_text.set_property('ellipsize', Pango.EllipsizeMode.END)
        col = Gtk.TreeViewColumn(Q_('?config:Preference Name'),
                                 renderer_text,
                                 text=0)
        treeview.insert_column(col, -1)
        col.props.expand = True
        col.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        col.set_resizable(True)

        self.renderer_text = Gtk.CellRendererText()
        self.renderer_text.connect('edited', self._on_config_edited)
        self.renderer_text.set_property('ellipsize', Pango.EllipsizeMode.END)
        col = Gtk.TreeViewColumn(Q_('?config:Value'),
                                 self.renderer_text,
                                 text=1)
        treeview.insert_column(col, -1)
        col.set_cell_data_func(self.renderer_text,
                               self._value_column_data_callback)
        col.props.expand = True
        col.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        col.set_resizable(True)

        renderer_text = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(Q_('?config:Type'), renderer_text, text=2)
        treeview.insert_column(col, -1)
        col.props.sizing = Gtk.TreeViewColumnSizing.FIXED

        treeview.set_model(self.modelfilter)

        self.connect_after('key-press-event', self._on_key_press)
        self._ui.connect_signals(self)
        self.show_all()
Esempio n. 5
0
def get_uf_show(show, use_mnemonic=False):
    """
    Return a userfriendly string for dnd/xa/chat and make all strings
    translatable

    If use_mnemonic is True, it adds _ so GUI should call with True for
    accessibility issues
    """
    if isinstance(show, ShowConstant):
        show = show.name.lower()

    if show == 'dnd':
        if use_mnemonic:
            uf_show = _('_Busy')
        else:
            uf_show = _('Busy')
    elif show == 'xa':
        if use_mnemonic:
            uf_show = _('_Not Available')
        else:
            uf_show = _('Not Available')
    elif show == 'chat':
        if use_mnemonic:
            uf_show = _('_Free for Chat')
        else:
            uf_show = _('Free for Chat')
    elif show == 'online':
        if use_mnemonic:
            uf_show = Q_('?user status:_Available')
        else:
            uf_show = Q_('?user status:Available')
    elif show == 'connecting':
        uf_show = _('Connecting')
    elif show == 'away':
        if use_mnemonic:
            uf_show = _('A_way')
        else:
            uf_show = _('Away')
    elif show == 'offline':
        if use_mnemonic:
            uf_show = _('_Offline')
        else:
            uf_show = _('Offline')
    elif show == 'not in roster':
        uf_show = _('Not in contact list')
    elif show == 'requested':
        uf_show = Q_('?contact has status:Unknown')
    else:
        uf_show = Q_('?contact has status:Has errors')
    return uf_show
Esempio n. 6
0
def get_uf_ask(ask):
    if ask is None:
        uf_ask = Q_('?Ask (for Subscription):None')
    elif ask == 'subscribe':
        uf_ask = _('Subscribe')
    else:
        uf_ask = ask

    return uf_ask
Esempio n. 7
0
    def _on_treeview_selection_changed(self, treeselection):
        model, iter_ = treeselection.get_selected()
        if not iter_:
            self._ui.reset_button.set_sensitive(False)
            return

        setting = model[iter_][Column.NAME]
        desc = ADVANCED_SETTINGS['app'][setting]

        self._ui.description.set_text(desc or Q_('?config description:None'))
        self._ui.reset_button.set_sensitive(True)
Esempio n. 8
0
def get_uf_sub(sub):
    if sub == 'none':
        uf_sub = Q_('?Subscription we already have:None')
    elif sub == 'to':
        uf_sub = _('To')
    elif sub == 'from':
        uf_sub = _('From')
    elif sub == 'both':
        uf_sub = _('Both')
    else:
        uf_sub = _('Unknown')

    return uf_sub
Esempio n. 9
0
    def set_os_info(self, task):
        error = False
        try:
            result = task.finish()
        except StanzaError:
            error = True

        jid = task.get_user_data()

        if self.xml.get_object('information_notebook').get_n_pages() < 5:
            return

        i = 0
        client = ''
        os_info = ''
        while i in self.os_info:
            if self.os_info[i]['resource'] == JID.from_string(jid).resource:
                if not error:
                    self.os_info[i]['client'] = '%s %s' % (result.name,
                                                           result.version)
                else:
                    self.os_info[i]['client'] = Q_('?Client:Unknown')

                if not error and result.os is not None:
                    self.os_info[i]['os'] = result.os
                else:
                    self.os_info[i]['os'] = Q_('?OS:Unknown')

            if i > 0:
                client += '\n'
                os_info += '\n'
            client += self.os_info[i]['client']
            os_info += self.os_info[i]['os']
            i += 1

        self.xml.get_object('client_name_version_label').set_text(client)
        self.xml.get_object('os_label').set_text(os_info)
        self.os_info_arrived = True
Esempio n. 10
0
    def set_os_info(self, obj):
        if obj.conn.name != self.account:
            return
        if self.xml.get_object('information_notebook').get_n_pages() < 5:
            return
        if self.gc_contact:
            if obj.jid != self.contact.jid:
                return
        elif obj.jid.getStripped() != self.contact.jid:
            return
        i = 0
        client = ''
        os = ''
        while i in self.os_info:
            if self.os_info[i]['resource'] == obj.jid.getResource():
                if obj.client_info:
                    self.os_info[i]['client'] = obj.client_info
                else:
                    self.os_info[i]['client'] = Q_('?Client:Unknown')
                if obj.os_info:
                    self.os_info[i]['os'] = obj.os_info
                else:
                    self.os_info[i]['os'] = Q_('?OS:Unknown')
            else:
                if not self.os_info[i]['client']:
                    self.os_info[i]['client'] = Q_('?Client:Unknown')
                if not self.os_info[i]['os']:
                    self.os_info[i]['os'] = Q_('?OS:Unknown')
            if i > 0:
                client += '\n'
                os += '\n'
            client += self.os_info[i]['client']
            os += self.os_info[i]['os']
            i += 1

        self.xml.get_object('client_name_version_label').set_text(client)
        self.xml.get_object('os_label').set_text(os)
        self.os_info_arrived = True
Esempio n. 11
0
    def _get_current_status(file_props):
        if file_props.stopped:
            return Q_('?transfer status:Aborted')
        if file_props.completed:
            return Q_('?transfer status:Completed')
        if file_props.paused:
            return Q_('?transfer status:Paused')
        if file_props.stalled:
            # stalled is not paused. it is like 'frozen' it stopped alone
            return Q_('?transfer status:Stalled')

        if file_props.connected:
            if file_props.started:
                return Q_('?transfer status:Transferring')
            return Q_('?transfer status:Not started')
        return Q_('?transfer status:Not started')
Esempio n. 12
0
 def colorize_affiliation(affiliation):
     """
     Color the affiliation of a MUC participant inside the tooltip by
     it's semantics. Color palette is the Tango.
     """
     formatted = "<span foreground='%s'>%s</span>"
     color = None
     if affiliation.startswith(Q_("?Group Chat Contact Affiliation:None")):
         color = app.config.get('tooltip_affiliation_none_color')
     elif affiliation.startswith(_("Member")):
         color = app.config.get('tooltip_affiliation_member_color')
     elif affiliation.startswith(_("Administrator")):
         color = app.config.get('tooltip_affiliation_administrator_color')
     elif affiliation.startswith(_("Owner")):
         color = app.config.get('tooltip_affiliation_owner_color')
     if color:
         affiliation = formatted % (color, affiliation)
     return affiliation
Esempio n. 13
0
def colorize_status(status):
    """
    Colorize the status message inside the tooltip by it's
    semantics. Color palette is the Tango.
    """
    formatted = "<span foreground='%s'>%s</span>"
    color = None
    if status.startswith(Q_("?user status:Available")):
        color = app.config.get('tooltip_status_online_color')
    elif status.startswith(_("Free for Chat")):
        color = app.config.get('tooltip_status_free_for_chat_color')
    elif status.startswith(_("Away")):
        color = app.config.get('tooltip_status_away_color')
    elif status.startswith(_("Busy")):
        color = app.config.get('tooltip_status_busy_color')
    elif status.startswith(_("Not Available")):
        color = app.config.get('tooltip_status_na_color')
    elif status.startswith(_("Offline")):
        color = app.config.get('tooltip_status_offline_color')
    if color:
        status = formatted % (color, status)
    return status
Esempio n. 14
0
 def _on_treeview_selection_changed(self, treeselection):
     model, iter_ = treeselection.get_selected()
     # Check for GtkTreeIter
     if iter_:
         opt_path = self._get_option_path(model, iter_)
         # Get text from first column in this row
         desc = None
         if len(opt_path) == 3:
             desc = app.config.get_desc_per(opt_path[2], opt_path[0])
         elif len(opt_path) == 1:
             desc = app.config.get_desc(opt_path[0])
         if desc:
             self._ui.description.set_text(desc)
         else:
             self._ui.description.set_text(Q_('?config description:None'))
         if (len(opt_path) == 3 or
                 (len(opt_path) == 1 and not model.iter_has_child(iter_))):
             self._ui.reset_button.set_sensitive(True)
         else:
             self._ui.reset_button.set_sensitive(False)
     else:
         self._ui.reset_button.set_sensitive(False)
Esempio n. 15
0
def get_uf_role(role, plural=False):
    ''' plural determines if you get Moderators or Moderator'''
    if not isinstance(role, str):
        role = role.value

    if role == 'none':
        role_name = Q_('?Group Chat Contact Role:None')
    elif role == 'moderator':
        if plural:
            role_name = _('Moderators')
        else:
            role_name = _('Moderator')
    elif role == 'participant':
        if plural:
            role_name = _('Participants')
        else:
            role_name = _('Participant')
    elif role == 'visitor':
        if plural:
            role_name = _('Visitors')
        else:
            role_name = _('Visitor')
    return role_name
Esempio n. 16
0
 def _fill_model(self, node=None, parent=None):
     for item, option in app.config.get_children(node):
         name = item[-1]
         if option is None:  # Node
             newparent = self.model.append(parent, [name, '', ''])
             self._fill_model(item, newparent)
         else:
             if len(item) == 1:
                 type_ = self.types[app.config.get_type(name)]
             elif len(item) == 3:
                 type_ = self.types[app.config.get_type_per(
                     item[0], item[2])]
             if name == 'password':
                 value = Q_('?password:Hidden')
             else:
                 if type_ == self.types['boolean']:
                     value = self.right_true_dict[option]
                 else:
                     try:
                         value = str(option)
                     except Exception:
                         value = option
             self.model.append(parent, [name, value, type_])
Esempio n. 17
0
def get_uf_affiliation(affiliation, plural=False):
    '''Get a nice and translated affilition for muc'''
    if not isinstance(affiliation, str):
        affiliation = affiliation.value

    if affiliation == 'none':
        affiliation_name = Q_('?Group Chat Contact Affiliation:None')
    elif affiliation == 'owner':
        if plural:
            affiliation_name = _('Owners')
        else:
            affiliation_name = _('Owner')
    elif affiliation == 'admin':
        if plural:
            affiliation_name = _('Administrators')
        else:
            affiliation_name = _('Administrator')
    elif affiliation == 'member':
        if plural:
            affiliation_name = _('Members')
        else:
            affiliation_name = _('Member')
    return affiliation_name
Esempio n. 18
0
        return self == ClientState.AVAILABLE


class JingleState(Enum):
    NULL = 'stop'
    CONNECTING = 'connecting'
    CONNECTION_RECEIVED = 'connection_received'
    CONNECTED = 'connected'
    ERROR = 'error'

    def __str__(self):
        return self.value


MUC_CREATION_EXAMPLES = [
    (Q_('?Group chat name:Team'),
     Q_('?Group chat description:Project discussion'),
     Q_('?Group chat address:team')),
    (Q_('?Group chat name:Family'),
     Q_('?Group chat description:Spring gathering'),
     Q_('?Group chat address:family')),
    (Q_('?Group chat name:Vacation'),
     Q_('?Group chat description:Trip planning'),
     Q_('?Group chat address:vacation')),
    (Q_('?Group chat name:Repairs'),
     Q_('?Group chat description:Local help group'),
     Q_('?Group chat address:repairs')),
    (Q_('?Group chat name:News'),
     Q_('?Group chat description:Local news and reports'),
     Q_('?Group chat address:news')),
]
Esempio n. 19
0
    def __init__(self):
        flags = Gtk.DialogFlags.DESTROY_WITH_PARENT
        super().__init__(_('Features'), None, flags)

        self.connect('key-press-event', self.on_key_press_event)
        self.set_transient_for(app.interface.roster.window)

        self.builder = get_builder('features_window.ui')
        content = self.get_content_area()
        content.add(self.builder.get_object('features_box'))

        treeview = self.builder.get_object('features_treeview')
        self.desc_label = self.builder.get_object('feature_desc_label')

        # {name: (available_function, unix_text, windows_text)}
        self.features = {
            _('Bonjour / Zeroconf'): (
                self.zeroconf_available,
                _('Serverless chatting with autodetected clients in a local network.'),
                _('Requires python-dbus.'),
                _('Requires pybonjour and bonjour SDK running (%(url)s)') % {'url': 'https://developer.apple.com/opensource/).'}),
            _('Command line'): (
                self.dbus_available,
                _('A script to control Gajim via commandline.'),
                _('Requires python-dbus.'),
                _('Feature not available under Windows.')),
            _('OpenPGP message encryption'): (
                self.gpg_available,
                _('Ability to encrypting chat messages with OpenPGP.'),
                _('Requires gpg and python-gnupg (%(url)s).') % {'url': 'https://bitbucket.org/vinay.sajip/python-gnupg'},
                _('Requires gpg.exe in PATH.')),
            _('Password encryption'): (
                self.some_keyring_available,
                _('Passwords can be stored securely and not just in plaintext.'),
                _('Requires libsecret and a provider (such as GNOME Keyring and KSecretService).'),
                _('On Windows the Windows Credential Vault is used.')),
            _('Spell Checker'): (
                self.speller_available,
                _('Spellchecking of composed messages.'),
                _('Requires Gspell'),
                _('Requires Gspell')),
            _('Automatic status'): (
                self.idle_available,
                _('Ability to measure idle time, in order to set auto status.'),
                _('Requires libxss library.'),
                _('Requires python2.5.')),
            _('RST Generator'): (
                self.docutils_available,
                _('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).'),
                _('Requires python-docutils.'),
                _('Requires python-docutils.')),
            _('Audio / Video'): (
                self.farstream_available,
                _('Ability to start audio and video chat.'),
                _('Requires gir1.2-farstream-0.2, gir1.2-gstreamer-1.0, gstreamer1.0-libav and gstreamer1.0-plugins-ugly.'),
                _('Feature not available under Windows.')),
            _('UPnP-IGD'): (
                self.gupnp_igd_available,
                _('Ability to request your router to forward port for file transfer.'),
                _('Requires gir1.2-gupnpigd-1.0.'),
                _('Feature not available under Windows.')),
        }

        # name, supported
        self.model = Gtk.ListStore(str, bool)
        treeview.set_model(self.model)

        col = Gtk.TreeViewColumn(Q_('?features:Available'))
        treeview.append_column(col)
        cell = Gtk.CellRendererToggle()
        cell.set_property('radio', True)
        col.pack_start(cell, True)
        col.add_attribute(cell, 'active', 1)

        col = Gtk.TreeViewColumn(_('Feature'))
        treeview.append_column(col)
        cell = Gtk.CellRendererText()
        col.pack_start(cell, True)
        col.add_attribute(cell, 'text', 0)

        # Fill model
        for feature in self.features:
            func = self.features[feature][0]
            rep = func()
            self.model.append([feature, rep])

        self.model.set_sort_column_id(0, Gtk.SortType.ASCENDING)

        self.builder.connect_signals(self)
        self.show_all()
Esempio n. 20
0
from gajim.common.i18n import _
from gajim.common.i18n import Q_
from gajim.common.const import URIType
from gajim.common.helpers import open_uri
from gajim.common.helpers import parse_uri
from gajim.common.structs import URI
from gajim.gui.util import gtk_month
from gajim.gui.util import python_month

LABEL_DICT = {
    'fn': _('Full Name'),
    'n': _('Name'),
    'bday': _('Birthday'),
    'gender': _('Gender'),
    'adr': Q_('?profile:Address'),
    'tel': _('Phone No.'),
    'email': _('Email'),
    'impp': _('IM Address'),
    'title': Q_('?profile:Title'),
    'role': Q_('?profile:Role'),
    'org': _('Organisation'),
    'note': Q_('?profile:Note'),
    'url': _('URL'),
    'key': Q_('?profile:Public Encryption Key'),
}

FIELD_TOOLTIPS = {'key': _('Your public key or authentication certificate')}

ADR_FIELDS = [
    'street', 'ext', 'pobox', 'code', 'locality', 'region', 'country'
Esempio n. 21
0
    def fill_jabber_page(self):
        self.xml.get_object('nickname_label').set_markup(
            '<b><span size="x-large">' + self.contact.get_shown_name() +
            '</span></b>')
        self.xml.get_object('jid_label').set_text(self.contact.jid)

        subscription_label = self.xml.get_object('subscription_label')
        ask_label = self.xml.get_object('ask_label')
        if self.gc_contact:
            self.xml.get_object('subscription_title_label').set_markup(
                Q_("?Role in Group Chat:<b>Role:</b>"))
            uf_role = helpers.get_uf_role(self.gc_contact.role)
            subscription_label.set_text(uf_role)

            self.xml.get_object('ask_title_label').set_markup(
                _("<b>Affiliation:</b>"))
            uf_affiliation = helpers.get_uf_affiliation(
                self.gc_contact.affiliation)
            ask_label.set_text(uf_affiliation)
        else:
            uf_sub = helpers.get_uf_sub(self.contact.sub)
            subscription_label.set_text(uf_sub)
            if self.contact.sub == 'from':
                tt_text = _(
                    "This contact is interested in your presence information, but you are not interested in their presence"
                )
            elif self.contact.sub == 'to':
                tt_text = _(
                    "You are interested in the contact's presence information, but it is not mutual"
                )
            elif self.contact.sub == 'both':
                tt_text = _(
                    "The contact and you want to exchange presence information"
                )
            else:  # None
                tt_text = _(
                    "You and the contact have a mutual disinterest in each-others presence information"
                )
            subscription_label.set_tooltip_text(tt_text)

            uf_ask = helpers.get_uf_ask(self.contact.ask)
            ask_label.set_text(uf_ask)
            if self.contact.ask == 'subscribe':
                tt_text = _(
                    "You are waiting contact's answer about your subscription request"
                )
            else:
                tt_text = _("There is no pending subscription request.")
            ask_label.set_tooltip_text(tt_text)

        resources = '%s (%s)' % (self.contact.resource,
                                 str(self.contact.priority))
        uf_resources = self.contact.resource + _(' resource with priority ')\
                + str(self.contact.priority)
        if not self.contact.status:
            self.contact.status = ''

        con = app.connections[self.account]

        # do not wait for os_info if contact is not connected or has error
        # additional check for observer is needed, as show is offline for him
        if self.contact.show in ('offline', 'error')\
        and not self.contact.is_observer():
            self.os_info_arrived = True
        else:  # Request os info if contact is connected
            if self.gc_contact:
                con.get_module('SoftwareVersion').request_software_version(
                    self.real_jid,
                    callback=self.set_os_info,
                    user_data=self.real_jid)
            else:
                jid = self.contact.get_full_jid()
                con.get_module('SoftwareVersion').request_software_version(
                    jid, callback=self.set_os_info, user_data=jid)

        # do not wait for entity_time if contact is not connected or has error
        # additional check for observer is needed, as show is offline for him
        if self.contact.show in ('offline', 'error')\
        and not self.contact.is_observer():
            self.entity_time_arrived = True
        else:  # Request entity time if contact is connected
            if self.gc_contact:
                j, r = app.get_room_and_nick_from_fjid(self.real_jid)
                GLib.idle_add(
                    con.get_module('EntityTime').request_entity_time, j, r)
            else:
                GLib.idle_add(
                    con.get_module('EntityTime').request_entity_time,
                    self.contact.jid, self.contact.resource)

        self.os_info = {
            0: {
                'resource': self.real_resource,
                'client': '',
                'os': ''
            }
        }
        self.time_info = {0: {'resource': self.real_resource, 'time': ''}}
        i = 1
        contact_list = app.contacts.get_contacts(self.account,
                                                 self.contact.jid)
        if contact_list:
            for c in contact_list:
                if c.resource != self.contact.resource:
                    resources += '\n%s (%s)' % (c.resource, str(c.priority))
                    uf_resources += '\n' + c.resource + \
                            _(' resource with priority ') + str(c.priority)
                    if c.show not in ('offline', 'error'):
                        jid = c.get_full_jid()
                        con.get_module(
                            'SoftwareVersion').request_software_version(
                                jid, callback=self.set_os_info, user_data=jid)
                        GLib.idle_add(
                            con.get_module('EntityTime').request_entity_time,
                            c.jid, c.resource)
                    self.os_info[i] = {
                        'resource': c.resource,
                        'client': '',
                        'os': ''
                    }
                    self.time_info[i] = {'resource': c.resource, 'time': ''}
                    i += 1

        self.xml.get_object('resource_prio_label').set_text(resources)
        resource_prio_label_eventbox = self.xml.get_object(
            'resource_prio_label_eventbox')
        resource_prio_label_eventbox.set_tooltip_text(uf_resources)

        self.fill_status_label()

        if self.gc_contact:
            con.get_module('VCardTemp').request_vcard(
                self._nec_vcard_received,
                self.gc_contact.get_full_jid(),
                room=True)
        else:
            con.get_module('VCardTemp').request_vcard(self._nec_vcard_received,
                                                      self.contact.jid)
Esempio n. 22
0
from nbxmpp.protocol import NS_MAM_1
from nbxmpp.protocol import NS_MAM_2

from gajim.common import app
from gajim.common.i18n import _
from gajim.common.i18n import Q_
from gajim.common.helpers import open_uri
from gajim.common.helpers import get_groupchat_name
from gajim.common.const import RFC5646_LANGUAGE_TAGS

from gajim.gtk.util import get_builder
from gajim.gtk.util import make_href_markup

MUC_FEATURES = {
    'mam': ('feather-server-symbolic', Q_('?Group chat feature:Archiving'),
            _('Messages are archived on the server')),
    'muc_persistent':
    ('feather-hard-drive-symbolic', Q_('?Group chat feature:Persistent'),
     _('This group chat persists '
       'even if there are no participants')),
    'muc_temporary':
    ('feather-clock-symbolic', Q_('?Group chat feature:Temporary'),
     _('This group chat will be destroyed '
       'once the last participant left')),
    'muc_moderated': ('feather-mic-off-symbolic',
                      Q_('?Group chat feature:Moderated'),
                      _('Participants entering this group chat need '
                        'to request permission to send messages')),
    'muc_unmoderated': ('feather-mic-symbolic',
                        Q_('?Group chat feature:Not Moderated'),
Esempio n. 23
0
 def get_setting_value(self):
     custom = app.settings.get_account_setting(self.account,
                                               'use_custom_host')
     return Q_('?switch:On') if custom else Q_('?switch:Off')
Esempio n. 24
0
from gajim.common.const import AvatarSize
from gajim.common.i18n import _
from gajim.common.i18n import Q_

from gajim.gui.avatar import clip_circle
from gajim.gui.avatar_selector import AvatarSelector
from gajim.gui.dialogs import ErrorDialog
from gajim.gui.filechoosers import AvatarChooserDialog
from gajim.gui.util import get_builder
from gajim.gui.vcard_grid import VCardGrid
from gajim.gui.util import scroll_to_end

log = logging.getLogger('gajim.gui.profile')

MENU_DICT = {
    'fn': Q_('?profile:Full Name'),
    'bday': _('Birthday'),
    'gender': Q_('?profile:Gender'),
    'adr': Q_('?profile:Address'),
    'email': _('Email'),
    'impp': Q_('?profile:IM Address'),
    'tel': _('Phone No.'),
    'org': Q_('?profile:Organisation'),
    'title': Q_('?profile:Title'),
    'role': Q_('?profile:Role'),
    'url': _('URL'),
    'key': Q_('?profile:Public Encryption Key'),
}


class ProfileWindow(Gtk.ApplicationWindow):
Esempio n. 25
0
 def get_setting_value(self):
     value = app.settings.get('show_notifications')
     return Q_('?switch:On') if value else Q_('?switch:Off')
Esempio n. 26
0
 def get_setting_value(self):
     value = app.settings.get('use_stun_server')
     return Q_('?switch:On') if value else Q_('?switch:Off')
Esempio n. 27
0
    def populate(self, file_props):
        ft_table = Gtk.Table(2, 1)
        ft_table.set_property('column-spacing', 2)
        current_row = 1
        self.create_window()
        properties = []
        name = file_props.name
        if file_props.type_ == 'r':
            file_name = os.path.split(file_props.file_name)[1]
        else:
            file_name = file_props.name
        properties.append((_('Name: '), GLib.markup_escape_text(file_name)))
        if file_props.type_ == 'r':
            type_ = Q_('?Noun:Download')
            actor = _('Sender: ')
            sender = file_props.sender.split('/')[0]
            name = app.contacts.get_first_contact_from_jid(
                    file_props.tt_account, sender).get_shown_name()
        else:
            type_ = Q_('?Noun:Upload')
            actor = _('Recipient: ')
            receiver = file_props.receiver
            if hasattr(receiver, 'name'):
                name = receiver.get_shown_name()
            else:
                name = receiver.split('/')[0]
        properties.append((_('Type: '), type_))
        properties.append((actor, GLib.markup_escape_text(name)))

        transfered_len = file_props.received_len
        if not transfered_len:
            transfered_len = 0
        properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len)))
        status = ''
        if file_props.started:
            status = _('Not started')
        if file_props.stopped == True:
            status = _('Stopped')
        elif file_props.completed:
            status = _('Completed')
        elif file_props.connected == False:
            if file_props.completed:
                status = _('Completed')
            else:
                if file_props.paused == True:
                    status = Q_('?transfer status:Paused')
                elif file_props.stalled == True:
                    #stalled is not paused. it is like 'frozen' it stopped alone
                    status = _('Stalled')
                else:
                    status = _('Transferring')
        else:
            status = _('Not started')
        properties.append((_('Status: '), status))
        file_desc = file_props.desc or ''
        properties.append((_('Description: '), GLib.markup_escape_text(
            file_desc)))
        while properties:
            property_ = properties.pop(0)
            current_row += 1
            label = Gtk.Label()
            label.set_halign(Gtk.Align.START)
            label.set_valign(Gtk.Align.START)
            label.set_markup(property_[0])
            ft_table.attach(label, 1, 2, current_row, current_row + 1,
                    Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 0, 0)
            label = Gtk.Label()
            label.set_halign(Gtk.Align.START)
            label.set_valign(Gtk.Align.START)
            label.set_line_wrap(True)
            label.set_markup(property_[1])
            ft_table.attach(label, 2, 3, current_row, current_row + 1,
                    Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 0, 0)

        self.win.add(ft_table)
Esempio n. 28
0
    def __init__(self):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_show_menubar(False)
        self.set_name('AdvancedConfig')
        self.set_title(_('Advanced Configuration Editor (ACE)'))

        self._ui = get_builder('advanced_configuration.ui')
        self.add(self._ui.box)

        # Format:
        # key = option name (root/subopt/opt separated by \n then)
        # value = array(oldval, newval)
        self.changed_opts = {}

        # For i18n
        self.right_true_dict = {True: _('Activated'), False: _('Deactivated')}
        self.types = {
            'boolean': Q_('?config type:Boolean'),
            'integer': Q_('?config type:Integer'),
            'string': Q_('?config type:Text'),
            'color': Q_('?config type:Color')}

        treeview = self._ui.advanced_treeview
        self.treeview = treeview
        self.model = Gtk.TreeStore(str, str, str)
        self._fill_model()
        self.model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
        self.modelfilter = self.model.filter_new()
        self.modelfilter.set_visible_func(self._visible_func)

        renderer_text = Gtk.CellRendererText()
        renderer_text.set_property('ellipsize', Pango.EllipsizeMode.END)
        col = Gtk.TreeViewColumn(Q_('?config:Preference Name'),
                                 renderer_text, text=0)
        treeview.insert_column(col, -1)
        col.props.expand = True
        col.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        col.set_resizable(True)

        self.renderer_text = Gtk.CellRendererText()
        self.renderer_text.connect('edited', self._on_config_edited)
        self.renderer_text.set_property('ellipsize', Pango.EllipsizeMode.END)
        col = Gtk.TreeViewColumn(
            Q_('?config:Value'), self.renderer_text, text=1)
        treeview.insert_column(col, -1)
        col.set_cell_data_func(self.renderer_text,
                               self._value_column_data_callback)
        col.props.expand = True
        col.props.sizing = Gtk.TreeViewColumnSizing.FIXED
        col.set_resizable(True)

        renderer_text = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(Q_('?config:Type'), renderer_text, text=2)
        treeview.insert_column(col, -1)
        col.props.sizing = Gtk.TreeViewColumnSizing.FIXED

        treeview.set_model(self.modelfilter)

        self.connect('key-press-event', self._on_key_press)
        self._ui.connect_signals(self)
        self.show_all()
Esempio n. 29
0
 def get_setting_value(self):
     value = app.settings.get('autoxa')
     return Q_('?switch:On') if value else Q_('?switch:Off')
Esempio n. 30
0
 def _set_label(self, active):
     text = Q_('?switch:On') if active else Q_('?switch:Off')
     self._switch_state_label.set_text(text)