Esempio n. 1
0
File: gui.py Progetto: gajim/gajim
    def __init__(self):
        '''Initialize Plugins window'''
        self.xml = gtkgui_helpers.get_gtk_builder('plugins_window.ui')
        self.window = self.xml.get_object('plugins_window')
        self.window.set_transient_for(gajim.interface.roster.window)

        widgets_to_extract = ('plugins_notebook', 'plugin_name_label',
            'plugin_version_label', 'plugin_authors_label',
            'plugin_homepage_linkbutton', 'uninstall_plugin_button',
            'configure_plugin_button', 'installed_plugins_treeview')

        for widget_name in widgets_to_extract:
            setattr(self, widget_name, self.xml.get_object(widget_name))

        self.plugin_description_textview = HtmlTextView()
        sw = self.xml.get_object('scrolledwindow2')
        sw.add(self.plugin_description_textview)
        self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
            GdkPixbuf.Pixbuf)
        self.installed_plugins_treeview.set_model(self.installed_plugins_model)
        self.installed_plugins_treeview.set_rules_hint(True)

        renderer = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(_('Plugin'))#, renderer, text=NAME)
        cell = Gtk.CellRendererPixbuf()
        col.pack_start(cell, False)
        col.add_attribute(cell, 'pixbuf', ICON)
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', NAME)
        col.set_property('expand', True)
        self.installed_plugins_treeview.append_column(col)

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self.installed_plugins_toggled_cb)
        col = Gtk.TreeViewColumn(_('Active'), renderer, active=ACTIVE,
            activatable=ACTIVATABLE)
        self.installed_plugins_treeview.append_column(col)

        self.def_icon = gtkgui_helpers.get_icon_pixmap('preferences-desktop')

        # connect signal for selection change
        selection = self.installed_plugins_treeview.get_selection()
        selection.connect('changed',
            self.installed_plugins_treeview_selection_changed)
        selection.set_mode(Gtk.SelectionMode.SINGLE)

        self._clear_installed_plugin_info()

        self.fill_installed_plugins_model()
        root_iter = self.installed_plugins_model.get_iter_first()
        if root_iter:
            selection.select_iter(root_iter )

        self.xml.connect_signals(self)

        self.plugins_notebook.set_current_page(0)
        self.xml.get_object('close_button').grab_focus()

        self.window.show_all()
        gtkgui_helpers.possibly_move_window_in_current_desktop(self.window)
Esempio n. 2
0
    def __init__(self, account, jid, commandnode=None):
        """
        Create new window
        """

        # an account object
        self.account = gajim.connections[account]
        self.jid = jid
        self.commandnode = commandnode
        self.data_form_widget = None

        # retrieving widgets from xml
        self.xml = gtkgui_helpers.get_gtk_builder('adhoc_commands_window.ui')
        self.window = self.xml.get_object('adhoc_commands_window')
        self.window.connect('delete-event',
            self.on_adhoc_commands_window_delete_event)
        for name in ('restart_button', 'back_button', 'forward_button',
        'execute_button', 'finish_button', 'close_button', 'stages_notebook',
        'retrieving_commands_stage_vbox', 'command_list_stage_vbox',
        'command_list_vbox', 'sending_form_stage_vbox',
        'sending_form_progressbar', 'notes_label', 'no_commands_stage_vbox',
        'error_stage_vbox', 'error_description_label'):
            setattr(self, name, self.xml.get_object(name))

        self.initiate()
Esempio n. 3
0
    def __init__(self, dataformnode=None):
        ''' Create a widget. '''
        GObject.GObject.__init__(self, xscale=1.0, yscale=1.0)

        self._data_form = None
        self.selectable = False

        self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
                                                  'data_form_vbox')
        self.xml.connect_signals(self)
        for name in ('instructions_label', 'instructions_hseparator',
                     'single_form_viewport', 'data_form_types_notebook',
                     'single_form_scrolledwindow', 'multiple_form_hbox',
                     'records_treeview', 'buttons_vbox', 'add_button',
                     'remove_button', 'edit_button', 'up_button',
                     'down_button', 'clear_button'):
            self.__dict__[name] = self.xml.get_object(name)

        self.add(self.xml.get_object('data_form_vbox'))

        if dataformnode is not None:
            self.set_data_form(dataformnode)

        selection = self.records_treeview.get_selection()
        selection.connect('changed', self.on_records_selection_changed)
        selection.set_mode(Gtk.SelectionMode.MULTIPLE)
Esempio n. 4
0
    def __init__(self, parent):
        Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP, transient_for=parent)
        StatusTable.__init__(self)
        self.create_table()
        self.row = None
        self.check_last_time = {}
        self.contact_jid = None
        self.last_widget = None
        self.num_resources = 0
        self.set_title('tooltip')
        self.set_border_width(3)
        self.set_resizable(False)
        self.set_name('gtk-tooltips')
        self.set_type_hint(Gdk.WindowTypeHint.TOOLTIP)

        self.xml = gtkgui_helpers.get_gtk_builder('tooltip_roster_contact.ui')
        for name in ('name', 'status', 'jid', 'user_show', 'fillelement',
            'resource', 'avatar', 'resource_label', 'pgp', 'pgp_label',
                'jid_label', 'tooltip_grid', 'idle_since', 'idle_for',
                'idle_since_label', 'idle_for_label', 'mood', 'tune',
                'activity', 'location', 'tune_label', 'location_label',
                'activity_label', 'mood_label', 'sub_label', 'sub',
                'status_label'):
            setattr(self, name, self.xml.get_object(name))

        self.add(self.tooltip_grid)
        self.tooltip_grid.show()
Esempio n. 5
0
    def __init__(self, account, jid):
        """
        Create new window
        """
        # an account object
        self.account = account
        self.jid = jid

        # retrieving widgets from xml
        self.xml = gtkgui_helpers.get_gtk_builder('search_window.ui')
        self.window = self.xml.get_object('search_window')
        for name in ('label', 'progressbar', 'search_vbox', 'search_button',
        'add_contact_button', 'information_button'):
            self.__dict__[name] = self.xml.get_object(name)

        self.search_button.set_sensitive(False)

        # displaying the window
        self.xml.connect_signals(self)
        self.window.show_all()
        self.request_form()
        self.pulse_id = GLib.timeout_add(80, self.pulse_callback)

        self.is_form = None

        # Is there a jid column in results ? if -1: no, else column number
        self.jid_column = -1

        gajim.ged.register_event_handler('search-form-received', ged.GUI1,
            self._nec_search_form_received)
        gajim.ged.register_event_handler('search-result-received', ged.GUI1,
            self._nec_search_result_received)
Esempio n. 6
0
    def __init__(self, dataformnode=None):
        ''' Create a widget. '''
        gtk.Alignment.__init__(self, xscale=1.0, yscale=1.0)

        self._data_form = None
        self.selectable = False

        self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
                'data_form_vbox')
        self.xml.connect_signals(self)
        for name in ('instructions_label', 'instructions_hseparator',
                        'single_form_viewport', 'data_form_types_notebook',
                        'single_form_scrolledwindow', 'multiple_form_hbox',
                        'records_treeview', 'buttons_vbox', 'add_button', 'remove_button',
                        'edit_button', 'up_button', 'down_button', 'clear_button'):
            self.__dict__[name] = self.xml.get_object(name)

        self.add(self.xml.get_object('data_form_vbox'))

        if dataformnode is not None:
            self.set_data_form(dataformnode)

        selection = self.records_treeview.get_selection()
        selection.connect('changed', self.on_records_selection_changed)
        selection.set_mode(gtk.SELECTION_MULTIPLE)
Esempio n. 7
0
    def __init__(self, account, transient_for=None):
        self.xml = gtkgui_helpers.get_gtk_builder('profile_window.ui')
        self.window = self.xml.get_object('profile_window')
        self.window.set_transient_for(transient_for)
        self.progressbar = self.xml.get_object('progressbar')
        self.statusbar = self.xml.get_object('statusbar')
        self.context_id = self.statusbar.get_context_id('profile')

        self.account = account
        self.jid = gajim.get_jid_from_account(account)

        self.dialog = None
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.message_id = self.statusbar.push(self.context_id,
                                              _('Retrieving profile...'))
        self.update_progressbar_timeout_id = GLib.timeout_add(
            100, self.update_progressbar)
        self.remove_statusbar_timeout_id = None

        # Create Image for avatar button
        image = Gtk.Image()
        self.xml.get_object('PHOTO_button').set_image(image)
        self.xml.connect_signals(self)
        gajim.ged.register_event_handler('vcard-published', ged.GUI1,
                                         self._nec_vcard_published)
        gajim.ged.register_event_handler('vcard-not-published', ged.GUI1,
                                         self._nec_vcard_not_published)
        gajim.ged.register_event_handler('vcard-received', ged.GUI1,
                                         self._nec_vcard_received)
        self.window.show_all()
        self.xml.get_object('ok_button').grab_focus()
Esempio n. 8
0
    def __init__(self,
                 type_id,
                 parent_win,
                 widget_name,
                 contact,
                 account,
                 resource=None):
        # dict { cb id : widget}
        # keep all registered callbacks of widgets, created by self.xml
        self.handlers = {}
        self.type_id = type_id
        self.parent_win = parent_win
        self.widget_name = widget_name
        self.contact = contact
        self.account = account
        self.hide_chat_buttons = False
        self.resource = resource

        self.session = None

        gajim.last_message_time[self.account][self.get_full_jid()] = 0

        self.xml = gtkgui_helpers.get_gtk_builder('%s.ui' % widget_name)
        self.widget = self.xml.get_object('%s_hbox' % widget_name)

        gajim.ged.register_event_handler('message-outgoing', ged.OUT_GUI1,
                                         self._nec_message_outgoing)
Esempio n. 9
0
    def __init__(self, account, jid, commandnode=None):
        """
        Create new window
        """

        # an account object
        self.account = gajim.connections[account]
        self.jid = jid
        self.commandnode = commandnode
        self.data_form_widget = None

        # retrieving widgets from xml
        self.xml = gtkgui_helpers.get_gtk_builder('adhoc_commands_window.ui')
        self.window = self.xml.get_object('adhoc_commands_window')
        self.window.connect('delete-event',
                            self.on_adhoc_commands_window_delete_event)
        for name in ('restart_button', 'back_button', 'forward_button',
                     'execute_button', 'finish_button', 'close_button',
                     'stages_notebook', 'retrieving_commands_stage_vbox',
                     'command_list_stage_vbox', 'command_list_vbox',
                     'sending_form_stage_vbox', 'sending_form_progressbar',
                     'notes_label', 'no_commands_stage_vbox',
                     'error_stage_vbox', 'error_description_label'):
            setattr(self, name, self.xml.get_object(name))

        self.initiate()
Esempio n. 10
0
    def __init__(self, account, jid):
        """
        Create new window
        """
        # an account object
        self.account = account
        self.jid = jid

        # retrieving widgets from xml
        self.xml = gtkgui_helpers.get_gtk_builder('search_window.ui')
        self.window = self.xml.get_object('search_window')
        for name in ('label', 'progressbar', 'search_vbox', 'search_button',
                     'add_contact_button', 'information_button'):
            self.__dict__[name] = self.xml.get_object(name)

        self.search_button.set_sensitive(False)

        # displaying the window
        self.xml.connect_signals(self)
        self.window.show_all()
        self.request_form()
        self.pulse_id = GLib.timeout_add(80, self.pulse_callback)

        self.is_form = None

        # Is there a jid column in results ? if -1: no, else column number
        self.jid_column = -1

        gajim.ged.register_event_handler('search-form-received', ged.GUI1,
                                         self._nec_search_form_received)
        gajim.ged.register_event_handler('search-result-received', ged.GUI1,
                                         self._nec_search_result_received)
Esempio n. 11
0
    def __init__(self, account, transient_for=None):
        self.xml = gtkgui_helpers.get_gtk_builder('profile_window.ui')
        self.window = self.xml.get_object('profile_window')
        self.window.set_transient_for(transient_for)
        self.progressbar = self.xml.get_object('progressbar')
        self.statusbar = self.xml.get_object('statusbar')
        self.context_id = self.statusbar.get_context_id('profile')

        self.account = account
        self.jid = gajim.get_jid_from_account(account)

        self.dialog = None
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.message_id = self.statusbar.push(self.context_id,
            _('Retrieving profile...'))
        self.update_progressbar_timeout_id = GLib.timeout_add(100,
            self.update_progressbar)
        self.remove_statusbar_timeout_id = None

        # Create Image for avatar button
        image = Gtk.Image()
        self.xml.get_object('PHOTO_button').set_image(image)
        self.xml.connect_signals(self)
        gajim.ged.register_event_handler('vcard-published', ged.GUI1,
            self._nec_vcard_published)
        gajim.ged.register_event_handler('vcard-not-published', ged.GUI1,
            self._nec_vcard_not_published)
        gajim.ged.register_event_handler('vcard-received', ged.GUI1,
            self._nec_vcard_received)
        self.window.show_all()
        self.xml.get_object('ok_button').grab_focus()
Esempio n. 12
0
 def show(self, parent=None):
     if self.window is None:
         builder = gtkgui_helpers.get_gtk_builder('shortcuts_window.ui')
         self.window = builder.get_object('shortcuts_window')
         self.window.connect('destroy', self._on_window_destroy)
     self.window.set_transient_for(parent)
     self.window.show_all()
     self.window.present()
Esempio n. 13
0
File: vcard.py Progetto: gajim/gajim
    def __init__(self, contact, account, gc_contact=None):
        # the contact variable is the jid if vcard is true
        self.xml = gtkgui_helpers.get_gtk_builder("vcard_information_window.ui")
        self.window = self.xml.get_object("vcard_information_window")
        self.progressbar = self.xml.get_object("progressbar")

        self.contact = contact
        self.account = account
        self.gc_contact = gc_contact

        # Get real jid
        if gc_contact:
            # Don't use real jid if room is (semi-)anonymous
            gc_control = gajim.interface.msg_win_mgr.get_gc_control(gc_contact.room_jid, account)
            if gc_contact.jid and not gc_control.is_anonymous:
                self.real_jid = gc_contact.jid
                self.real_jid_for_vcard = gc_contact.jid
                if gc_contact.resource:
                    self.real_jid += "/" + gc_contact.resource
            else:
                self.real_jid = gc_contact.get_full_jid()
                self.real_jid_for_vcard = self.real_jid
            self.real_resource = gc_contact.name
        else:
            self.real_jid = contact.get_full_jid()
            self.real_resource = contact.resource

        puny_jid = helpers.sanitize_filename(contact.jid)
        local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid) + "_local"
        for extension in (".png", ".jpeg"):
            local_avatar_path = local_avatar_basepath + extension
            if os.path.isfile(local_avatar_path):
                image = self.xml.get_object("custom_avatar_image")
                image.set_from_file(local_avatar_path)
                image.show()
                self.xml.get_object("custom_avatar_label").show()
                break
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.vcard_arrived = False
        self.os_info_arrived = False
        self.entity_time_arrived = False
        self.update_progressbar_timeout_id = GLib.timeout_add(100, self.update_progressbar)

        gajim.ged.register_event_handler("version-result-received", ged.GUI1, self.set_os_info)
        gajim.ged.register_event_handler("last-result-received", ged.GUI2, self.set_last_status_time)
        gajim.ged.register_event_handler("time-result-received", ged.GUI1, self.set_entity_time)
        gajim.ged.register_event_handler("vcard-received", ged.GUI1, self._nec_vcard_received)

        self.fill_jabber_page()
        annotations = gajim.connections[self.account].annotations
        if self.contact.jid in annotations:
            buffer_ = self.xml.get_object("textview_annotation").get_buffer()
            buffer_.set_text(annotations[self.contact.jid])

        self.xml.connect_signals(self)
        self.xml.get_object("close_button").grab_focus()
        self.window.show_all()
Esempio n. 14
0
    def make_link_menu(self, event, kind, text):
        from gtkgui_helpers import get_gtk_builder
        xml = get_gtk_builder('chat_context_menu.ui')
        menu = xml.get_object('chat_context_menu')
        childs = menu.get_children()
        if kind == 'url':
            childs[0].connect('activate', self.on_copy_link_activate, text)
            childs[1].connect('activate', self.on_open_link_activate, kind,
                              text)
            childs[2].hide()  # copy mail address
            childs[3].hide()  # open mail composer
            childs[4].hide()  # jid section separator
            childs[5].hide()  # start chat
            childs[6].hide()  # join group chat
            childs[7].hide()  # add to roster
        else:  # It's a mail or a JID
            # load muc icon
            join_group_chat_menuitem = xml.get_object(
                'join_group_chat_menuitem')
            muc_icon = gtkgui_helpers.load_icon('muc_active')
            if muc_icon:
                join_group_chat_menuitem.set_image(muc_icon)

            text = text.lower()
            if text.startswith('xmpp:'):
                text = text[5:]
            childs[2].connect('activate', self.on_copy_link_activate, text)
            childs[3].connect('activate', self.on_open_link_activate, kind,
                              text)
            #            childs[5].connect('activate', self.on_start_chat_activate, text)
            childs[6].connect('activate',
                              self.on_join_group_chat_menuitem_activate, text)

            #            if self.account and gajim.connections[self.account].\
            #            roster_supported:
            #                childs[7].connect('activate',
            #                    self.on_add_to_roster_activate, text)
            #                childs[7].show() # show add to roster menuitem
            #            else:
            #                childs[7].hide() # hide add to roster menuitem

            if kind == 'xmpp':
                childs[0].connect('activate', self.on_copy_link_activate,
                                  'xmpp:' + text)
                childs[2].hide()  # copy mail address
                childs[3].hide()  # open mail composer
            elif kind == 'mail':
                childs[6].hide()  # join group chat

            if kind != 'xmpp':
                childs[0].hide()  # copy link location
            childs[1].hide()  # open link in browser
            childs[4].hide()  # jid section separator
            childs[5].hide()  # start chat
            childs[7].hide()  # add to roster

        menu.popup(None, None, None, event.button, event.time)
Esempio n. 15
0
    def make_link_menu(self, event, kind, text):
        from gtkgui_helpers import get_gtk_builder, load_icon
        xml = get_gtk_builder('chat_context_menu.ui')
        menu = xml.get_object('chat_context_menu')
        childs = menu.get_children()
        if kind == 'url':
            childs[0].connect('activate', self.on_copy_link_activate, text)
            childs[1].connect('activate', self.on_open_link_activate, kind,
                text)
            childs[2].hide() # copy mail address
            childs[3].hide() # open mail composer
            childs[4].hide() # jid section separator
            childs[5].hide() # start chat
            childs[6].hide() # join group chat
            childs[7].hide() # add to roster
        else: # It's a mail or a JID
            # load muc icon
            join_group_chat_menuitem = xml.get_object('join_group_chat_menuitem')
            muc_icon = load_icon('muc_active')
            if muc_icon:
                join_group_chat_menuitem.set_image(muc_icon)

            text = text.lower()
            if text.startswith('xmpp:'):
                text = text[5:]
            childs[2].connect('activate', self.on_copy_link_activate, text)
            childs[3].connect('activate', self.on_open_link_activate, kind,
                text)
#            childs[5].connect('activate', self.on_start_chat_activate, text)
            childs[6].connect('activate',
                self.on_join_group_chat_menuitem_activate, text)

#            if self.account and gajim.connections[self.account].\
#            roster_supported:
#                childs[7].connect('activate',
#                    self.on_add_to_roster_activate, text)
#                childs[7].show() # show add to roster menuitem
#            else:
#                childs[7].hide() # hide add to roster menuitem

            if kind == 'xmpp':
                childs[0].connect('activate', self.on_copy_link_activate,
                    'xmpp:' + text)
                childs[2].hide() # copy mail address
                childs[3].hide() # open mail composer
            elif kind == 'mail':
                childs[6].hide() # join group chat

            if kind != 'xmpp':
                childs[0].hide() # copy link location
            childs[1].hide() # open link in browser
            childs[4].hide() # jid section separator
            childs[5].hide() # start chat
            childs[7].hide() # add to roster

        menu.popup(None, None, None, event.button, event.time)
Esempio n. 16
0
    def on_listview_button_press_event(self, widget, event):
        if event.button == 3:  # right click
            xml = gtkgui_helpers.get_gtk_builder("history_manager.ui", "context_menu")
            if gtk.Buildable.get_name(widget) != "jids_listview":
                xml.get_object("export_menuitem").hide()
            xml.get_object("delete_menuitem").connect("activate", self.on_delete_menuitem_activate, widget)

            xml.connect_signals(self)
            xml.get_object("context_menu").popup(None, None, None, event.button, event.time)
            return True
Esempio n. 17
0
 def __init__(self, plugin, chat_control, event):
     self.plugin = plugin
     self.event = event
     self.xml = gtkgui_helpers.get_gtk_builder(
         self.plugin.local_file_path('download_progress_dialog.ui'))
     self.dialog = self.xml.get_object('progress_dialog')
     self.dialog.set_transient_for(chat_control.parent_win.window)
     self.label = self.xml.get_object('label')
     self.progressbar = self.xml.get_object('progressbar')
     self.progressbar.set_text("")
     self.dialog.show_all()
     self.xml.connect_signals(self)
     self.seen = 0
Esempio n. 18
0
 def __init__(self):
     self.single_message_handler_id = None
     self.show_roster_handler_id = None
     self.new_chat_handler_id = None
     # click somewhere else does not popdown menu. workaround this.
     self.added_hide_menuitem = False
     self.status = 'offline'
     self.xml = gtkgui_helpers.get_gtk_builder('systray_context_menu.ui')
     self.systray_context_menu = self.xml.get_object('systray_context_menu')
     self.xml.connect_signals(self)
     self.popup_menus = []
     self.status_icon = None
     self.tooltip = tooltips.NotificationAreaTooltip()
Esempio n. 19
0
 def __init__(self):
     self.single_message_handler_id = None
     self.show_roster_handler_id = None
     self.new_chat_handler_id = None
     # click somewhere else does not popdown menu. workaround this.
     self.added_hide_menuitem = False
     self.status = 'offline'
     self.xml = gtkgui_helpers.get_gtk_builder('systray_context_menu.ui')
     self.systray_context_menu = self.xml.get_object('systray_context_menu')
     self.xml.connect_signals(self)
     self.popup_menus = []
     self.status_icon = None
     self.tooltip = tooltips.NotificationAreaTooltip()
Esempio n. 20
0
    def on_listview_button_press_event(self, widget, event):
        if event.button == 3:  # right click
            xml = gtkgui_helpers.get_gtk_builder('history_manager.ui',
                                                 'context_menu')
            if Gtk.Buildable.get_name(widget) != 'jids_listview':
                xml.get_object('export_menuitem').hide()
            xml.get_object('delete_menuitem').connect(
                'activate', self.on_delete_menuitem_activate, widget)

            xml.connect_signals(self)
            xml.get_object('context_menu').popup(None, None, None, None,
                                                 event.button, event.time)
            return True
Esempio n. 21
0
    def on_listview_button_press_event(self, widget, event):
        if event.button == 3:  # right click
            xml = gtkgui_helpers.get_gtk_builder('history_manager.ui',
                'context_menu')
            if Gtk.Buildable.get_name(widget) != 'jids_listview':
                xml.get_object('export_menuitem').hide()
            xml.get_object('delete_menuitem').connect('activate',
                    self.on_delete_menuitem_activate, widget)

            xml.connect_signals(self)
            xml.get_object('context_menu').popup(None, None, None, None,
                    event.button, event.time)
            return True
Esempio n. 22
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_gtk_builder('gajim_themes_window.ui')
        self.window = self.xml.get_object('gajim_themes_window')
        self.window.set_transient_for(
            gajim.interface.instances['preferences'].window)

        self.options = ['account', 'group', 'contact', 'banner']
        self.options_combobox = self.xml.get_object('options_combobox')
        self.textcolor_checkbutton = self.xml.get_object(
            'textcolor_checkbutton')
        self.background_checkbutton = self.xml.get_object(
            'background_checkbutton')
        self.textfont_checkbutton = self.xml.get_object('textfont_checkbutton')
        self.text_colorbutton = self.xml.get_object('text_colorbutton')
        self.background_colorbutton = self.xml.get_object(
            'background_colorbutton')
        self.text_fontbutton = self.xml.get_object('text_fontbutton')
        self.bold_togglebutton = self.xml.get_object('bold_togglebutton')
        self.italic_togglebutton = self.xml.get_object('italic_togglebutton')
        self.themes_tree = self.xml.get_object('themes_treeview')
        self.theme_options_vbox = self.xml.get_object('theme_options_vbox')
        self.theme_options_table = self.xml.get_object('theme_options_table')
        self.colorbuttons = {}
        for chatstate in ('inactive', 'composing', 'paused', 'gone', 'muc_msg',
                          'muc_directed_msg'):
            self.colorbuttons[chatstate] = self.xml.get_object(chatstate + \
                    '_colorbutton')
        model = Gtk.ListStore(str)
        self.themes_tree.set_model(model)
        col = Gtk.TreeViewColumn(_('Theme'))
        self.themes_tree.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', 0)
        renderer.connect('edited', self.on_theme_cell_edited)
        renderer.set_property('editable', True)
        self.current_theme = gajim.config.get('roster_theme')
        self.no_update = False
        self.fill_themes_treeview()
        self.select_active_theme()
        self.current_option = self.options[0]
        self.set_theme_options(self.current_theme, self.current_option)

        self.xml.connect_signals(self)
        self.window.connect('delete-event',
                            self.on_themese_window_delete_event)
        self.themes_tree.get_selection().connect('changed',
                                                 self.selection_changed)
        self.window.show_all()
Esempio n. 23
0
    def new_tab(self, control):
        fjid = control.get_full_jid()

        if control.account not in self._controls:
            self._controls[control.account] = {}

        self._controls[control.account][fjid] = control

        if self.get_num_controls() == 2:
            # is first conversation_textview scrolled down ?
            scrolled = False
            first_widget = self.notebook.get_nth_page(0)
            ctrl = self._widget_to_control(first_widget)
            conv_textview = ctrl.conv_textview
            if conv_textview.at_the_end():
                scrolled = True
            self.notebook.set_show_tabs(True)
            if scrolled:
                GLib.idle_add(conv_textview.scroll_to_end_iter)

        # Add notebook page and connect up to the tab's close button
        xml = gtkgui_helpers.get_gtk_builder('message_window.ui', 'chat_tab_ebox')
        tab_label_box = xml.get_object('chat_tab_ebox')
        widget = xml.get_object('tab_close_button')
        # this reduces the size of the button
#        style = Gtk.RcStyle()
#        style.xthickness = 0
#        style.ythickness = 0
#        widget.modify_style(style)

        id_ = widget.connect('clicked', self._on_close_button_clicked, control)
        control.handlers[id_] = widget

        id_ = tab_label_box.connect('button-press-event',
            self.on_tab_eventbox_button_press_event, control.widget)
        control.handlers[id_] = tab_label_box
        self.notebook.append_page(control.widget, tab_label_box)

        self.notebook.set_tab_reorderable(control.widget, True)

        self.redraw_tab(control)
        if self.parent_paned:
            self.notebook.show_all()
        else:
            self.window.show_all()
        # NOTE: we do not call set_control_active(True) since we don't know
        # whether the tab is the active one.
        self.show_title()
        GLib.timeout_add(500, control.msg_textview.grab_focus)
Esempio n. 24
0
    def on_export_menuitem_activate(self, widget):
        xml = gtkgui_helpers.get_gtk_builder("history_manager.ui", "filechooserdialog")
        xml.connect_signals(self)

        dlg = xml.get_object("filechooserdialog")
        dlg.set_title(_("Exporting History Logs..."))
        dlg.set_current_folder(gajim.HOME_DIR)
        dlg.props.do_overwrite_confirmation = True
        response = dlg.run()

        if response == gtk.RESPONSE_OK:  # user want us to export ;)
            liststore, list_of_paths = self.jids_listview.get_selection().get_selected_rows()
            path_to_file = dlg.get_filename()
            self._export_jids_logs_to_file(liststore, list_of_paths, path_to_file)

        dlg.destroy()
Esempio n. 25
0
    def __init__(self):
        pixs = []
        for size in (16, 32, 48, 64, 128):
            pix = gtkgui_helpers.get_icon_pixmap('gajim', size)
            if pix:
                pixs.append(pix)
        if pixs:
            # set the icon to all windows
            Gtk.Window.set_default_icon_list(pixs)

        if not os.path.exists(LOG_DB_PATH):
            dialogs.ErrorDialog(_('Cannot find history logs database'),
                                '%s does not exist.' % LOG_DB_PATH)
            sys.exit()

        xml = gtkgui_helpers.get_gtk_builder('history_manager.ui')
        self.window = xml.get_object('history_manager_window')
        self.jids_listview = xml.get_object('jids_listview')
        self.logs_listview = xml.get_object('logs_listview')
        self.search_results_listview = xml.get_object(
            'search_results_listview')
        self.search_entry = xml.get_object('search_entry')
        self.logs_scrolledwindow = xml.get_object('logs_scrolledwindow')
        self.search_results_scrolledwindow = xml.get_object(
            'search_results_scrolledwindow')
        self.welcome_vbox = xml.get_object('welcome_vbox')

        self.jids_already_in = []  # holds jids that we already have in DB
        self.AT_LEAST_ONE_DELETION_DONE = False

        self.con = sqlite.connect(LOG_DB_PATH,
                                  timeout=20.0,
                                  isolation_level='IMMEDIATE')
        self.cur = self.con.cursor()

        self._init_jids_listview()
        self._init_logs_listview()
        self._init_search_results_listview()

        self._fill_jids_listview()

        self.search_entry.grab_focus()

        self.window.show_all()

        xml.connect_signals(self)
Esempio n. 26
0
    def __init__(self, contact, account, is_fake = False):
        # the contact variable is the jid if vcard is true
        self.xml = gtkgui_helpers.get_gtk_builder('zeroconf_information_window.ui')
        self.window = self.xml.get_object('zeroconf_information_window')

        self.contact = contact
        self.account = account
        self.is_fake = is_fake

    #       self.avatar_mime_type = None
    #       self.avatar_encoded = None

        self.fill_contact_page()
        self.fill_personal_page()

        self.xml.connect_signals(self)
        self.window.show_all()
Esempio n. 27
0
    def __init__(self, account, jid, session, form):
        self.account = account
        self.jid = jid
        self.form = form
        self.session = session

        self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui', 'data_form_window')
        self.window = self.xml.get_object('data_form_window')

        config_vbox = self.xml.get_object('config_vbox')
        dataform = dataforms.ExtendForm(node = self.form)
        self.data_form_widget = dataforms_widget.DataFormWidget(dataform)
        self.data_form_widget.show()
        config_vbox.pack_start(self.data_form_widget, True, True, 0)

        self.xml.connect_signals(self)
        self.window.show_all()
Esempio n. 28
0
    def __init__(self, parent):
        Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP, transient_for=parent)
        self.row = None
        self.set_title('tooltip')
        self.set_border_width(3)
        self.set_resizable(False)
        self.set_name('gtk-tooltips')
        self.set_type_hint(Gdk.WindowTypeHint.TOOLTIP)

        self.xml = gtkgui_helpers.get_gtk_builder('tooltip_gc_contact.ui')
        for name in ('nick', 'status', 'jid', 'user_show', 'fillelement',
            'resource', 'affiliation', 'avatar', 'resource_label',
                'jid_label', 'tooltip_grid'):
            setattr(self, name, self.xml.get_object(name))

        self.add(self.tooltip_grid)
        self.tooltip_grid.show()
Esempio n. 29
0
    def __init__(self, contact, account, is_fake = False):
        # the contact variable is the jid if vcard is true
        self.xml = gtkgui_helpers.get_gtk_builder('zeroconf_information_window.ui')
        self.window = self.xml.get_object('zeroconf_information_window')

        self.contact = contact
        self.account = account
        self.is_fake = is_fake

    #       self.avatar_mime_type = None
    #       self.avatar_encoded = None

        self.fill_contact_page()
        self.fill_personal_page()

        self.xml.connect_signals(self)
        self.window.show_all()
Esempio n. 30
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_gtk_builder('gajim_themes_window.ui')
        self.window = self.xml.get_object('gajim_themes_window')
        self.window.set_transient_for(gajim.interface.instances[
            'preferences'].window)

        self.options = ['account', 'group', 'contact', 'banner']
        self.options_combobox = self.xml.get_object('options_combobox')
        self.textcolor_checkbutton = self.xml.get_object('textcolor_checkbutton')
        self.background_checkbutton = self.xml.get_object('background_checkbutton')
        self.textfont_checkbutton = self.xml.get_object('textfont_checkbutton')
        self.text_colorbutton = self.xml.get_object('text_colorbutton')
        self.background_colorbutton = self.xml.get_object('background_colorbutton')
        self.text_fontbutton = self.xml.get_object('text_fontbutton')
        self.bold_togglebutton = self.xml.get_object('bold_togglebutton')
        self.italic_togglebutton = self.xml.get_object('italic_togglebutton')
        self.themes_tree = self.xml.get_object('themes_treeview')
        self.theme_options_vbox = self.xml.get_object('theme_options_vbox')
        self.theme_options_table = self.xml.get_object('theme_options_table')
        self.colorbuttons = {}
        for chatstate in ('inactive', 'composing', 'paused', 'gone',
        'muc_msg', 'muc_directed_msg'):
            self.colorbuttons[chatstate] = self.xml.get_object(chatstate + \
                    '_colorbutton')
        model = Gtk.ListStore(str)
        self.themes_tree.set_model(model)
        col = Gtk.TreeViewColumn(_('Theme'))
        self.themes_tree.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', 0)
        renderer.connect('edited', self.on_theme_cell_edited)
        renderer.set_property('editable', True)
        self.current_theme = gajim.config.get('roster_theme')
        self.no_update = False
        self.fill_themes_treeview()
        self.select_active_theme()
        self.current_option = self.options[0]
        self.set_theme_options(self.current_theme, self.current_option)

        self.xml.connect_signals(self)
        self.window.connect('delete-event', self.on_themese_window_delete_event)
        self.themes_tree.get_selection().connect('changed',
                        self.selection_changed)
        self.window.show_all()
Esempio n. 31
0
    def __init__(self, account, jid, session, form):
        self.account = account
        self.jid = jid
        self.form = form
        self.session = session

        self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
                                                  'data_form_window')
        self.window = self.xml.get_object('data_form_window')

        config_vbox = self.xml.get_object('config_vbox')
        dataform = dataforms.ExtendForm(node=self.form)
        self.data_form_widget = dataforms_widget.DataFormWidget(dataform)
        self.data_form_widget.show()
        config_vbox.pack_start(self.data_form_widget, True, True, 0)

        self.xml.connect_signals(self)
        self.window.show_all()
Esempio n. 32
0
    def __init__(self):
        pixs = []
        for size in (16, 32, 48, 64, 128):
            pix = gtkgui_helpers.get_icon_pixmap('gajim', size)
            if pix:
                pixs.append(pix)
        if pixs:
            # set the icon to all windows
            Gtk.Window.set_default_icon_list(pixs)

        if not os.path.exists(LOG_DB_PATH):
            dialogs.ErrorDialog(_('Cannot find history logs database'),
                    '%s does not exist.' % LOG_DB_PATH)
            sys.exit()

        xml = gtkgui_helpers.get_gtk_builder('history_manager.ui')
        self.window = xml.get_object('history_manager_window')
        self.jids_listview = xml.get_object('jids_listview')
        self.logs_listview = xml.get_object('logs_listview')
        self.search_results_listview = xml.get_object('search_results_listview')
        self.search_entry = xml.get_object('search_entry')
        self.logs_scrolledwindow = xml.get_object('logs_scrolledwindow')
        self.search_results_scrolledwindow = xml.get_object(
                'search_results_scrolledwindow')
        self.welcome_vbox = xml.get_object('welcome_vbox')

        self.jids_already_in = []  # holds jids that we already have in DB
        self.AT_LEAST_ONE_DELETION_DONE = False

        self.con = sqlite.connect(LOG_DB_PATH, timeout=20.0,
                isolation_level='IMMEDIATE')
        self.cur = self.con.cursor()

        self._init_jids_listview()
        self._init_logs_listview()
        self._init_search_results_listview()

        self._fill_jids_listview()

        self.search_entry.grab_focus()

        self.window.show_all()

        xml.connect_signals(self)
Esempio n. 33
0
    def on_export_menuitem_activate(self, widget):
        xml = gtkgui_helpers.get_gtk_builder('history_manager.ui',
                                             'filechooserdialog')
        xml.connect_signals(self)

        dlg = xml.get_object('filechooserdialog')
        dlg.set_title(_('Exporting History Logs…'))
        dlg.set_current_folder(gajim.HOME_DIR)
        dlg.props.do_overwrite_confirmation = True
        response = dlg.run()

        if response == Gtk.ResponseType.OK:  # user want us to export ;)
            liststore, list_of_paths = self.jids_listview.get_selection()\
                    .get_selected_rows()
            path_to_file = dlg.get_filename()
            self._export_jids_logs_to_file(liststore, list_of_paths,
                                           path_to_file)

        dlg.destroy()
Esempio n. 34
0
    def __init__(self, account, servicejid, groupid):
        """
        Open new 'create post' window to create message for groupid on servicejid
        service
        """
        assert isinstance(servicejid, str)
        assert isinstance(groupid, str)

        self.account = account
        self.servicejid = servicejid
        self.groupid = groupid

        self.xml = gtkgui_helpers.get_gtk_builder('groups_post_window.ui')
        self.window = self.xml.get_object('groups_post_window')
        for name in ('from_entry', 'subject_entry', 'contents_textview'):
            self.__dict__[name] = self.xml.get_object(name)

        self.xml.connect_signals(self)
        self.window.show_all()
Esempio n. 35
0
    def __init__(self, title_text, during_text, messages_queue, plugin):
        self.plugin = plugin
        self.xml = gtkgui_helpers.get_gtk_builder(self.plugin.local_file_path('upload_progress_dialog.ui'))
        self.messages_queue = messages_queue
        self.dialog = self.xml.get_object('progress_dialog')
        self.label = self.xml.get_object('label')
        self.cancel_button = self.xml.get_object('close_button')
        self.label.set_markup('<big>' + during_text + '</big>')
        self.progressbar = self.xml.get_object('progressbar')
        self.progressbar.set_text("")
        self.dialog.set_title(title_text)
        self.dialog.set_geometry_hints(min_width=400, min_height=96)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.show_all()
        self.xml.connect_signals(self)

        self.stopped = False
        self.pulse_progressbar_timeout_id = gobject.timeout_add(100, self.pulse_progressbar)
        self.process_messages_queue_timeout_id = gobject.timeout_add(100, self.process_messages_queue)
Esempio n. 36
0
    def __init__(self, during_text, messages_queue, plugin, event):
        self.plugin = plugin
        self.event = event
        self.xml = gtkgui_helpers.get_gtk_builder(
            self.plugin.local_file_path('upload_progress_dialog.ui'))
        self.messages_queue = messages_queue
        self.dialog = self.xml.get_object('progress_dialog')
        self.dialog.set_transient_for(plugin.chat_control.parent_win.window)
        self.label = self.xml.get_object('label')
        self.label.set_markup('<big>' + during_text + '</big>')
        self.progressbar = self.xml.get_object('progressbar')
        self.progressbar.set_text("")
        self.dialog.show_all()
        self.xml.connect_signals(self)

        self.pulse_progressbar_timeout_id = gobject.timeout_add(
            100, self.pulse_progressbar)
        self.process_messages_queue_timeout_id = gobject.timeout_add(
            100, self.process_messages_queue)
Esempio n. 37
0
File: groups.py Progetto: irl/gajim
    def __init__(self, account, servicejid, groupid):
        """
        Open new 'create post' window to create message for groupid on servicejid
        service
        """
        assert isinstance(servicejid, basestring)
        assert isinstance(groupid, basestring)

        self.account = account
        self.servicejid = servicejid
        self.groupid = groupid

        self.xml = gtkgui_helpers.get_gtk_builder('groups_post_window.ui')
        self.window = self.xml.get_object('groups_post_window')
        for name in ('from_entry', 'subject_entry', 'contents_textview'):
            self.__dict__[name] = self.xml.get_object(name)

        self.xml.connect_signals(self)
        self.window.show_all()
Esempio n. 38
0
    def __init__(self, type_id, parent_win, widget_name, contact, account,
    resource=None):
        # dict { cb id : widget}
        # keep all registered callbacks of widgets, created by self.xml
        self.handlers = {}
        self.type_id = type_id
        self.parent_win = parent_win
        self.widget_name = widget_name
        self.contact = contact
        self.account = account
        self.hide_chat_buttons = False
        self.resource = resource

        self.session = None

        gajim.last_message_time[self.account][self.get_full_jid()] = 0

        self.xml = gtkgui_helpers.get_gtk_builder('%s.ui' % widget_name)
        self.widget = self.xml.get_object('%s_hbox' % widget_name)

        gajim.ged.register_event_handler('message-outgoing', ged.OUT_GUI1,
            self._nec_message_outgoing)
Esempio n. 39
0
    def __init__(self):
        """
        Create new window... only if we have anything to show
        """
        assert len(self.__class__.entries)

        self.entry = None  # the entry actually displayed

        self.xml = gtkgui_helpers.get_gtk_builder('atom_entry_window.ui')
        self.window = self.xml.get_object('atom_entry_window')
        for name in ('new_entry_label', 'feed_title_label',
                     'feed_title_eventbox', 'feed_tagline_label',
                     'entry_title_label', 'entry_title_eventbox',
                     'last_modified_label', 'close_button', 'next_button'):
            self.__dict__[name] = self.xml.get_object(name)

        self.displayNextEntry()

        self.xml.connect_signals(self)
        self.window.show_all()

        self.entry_title_eventbox.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
        self.feed_title_eventbox.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
Esempio n. 40
0
    def __init__(self):
        """
        Create new window... only if we have anything to show
        """
        assert len(self.__class__.entries)

        self.entry = None # the entry actually displayed

        self.xml = gtkgui_helpers.get_gtk_builder('atom_entry_window.ui')
        self.window = self.xml.get_object('atom_entry_window')
        for name in ('new_entry_label', 'feed_title_label',
        'feed_title_eventbox', 'feed_tagline_label', 'entry_title_label',
        'entry_title_eventbox', 'last_modified_label', 'close_button',
        'next_button'):
            self.__dict__[name] = self.xml.get_object(name)

        self.displayNextEntry()

        self.xml.connect_signals(self)
        self.window.show_all()

        self.entry_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.feed_title_eventbox.add_events(gtk.gdk.BUTTON_PRESS_MASK)
Esempio n. 41
0
    def __init__(self, account, jid, commandnode=None):
        """
        Create new window
        """

        # an account object
        self.account = gajim.connections[account]
        self.jid = jid
        self.commandnode = commandnode
        self.data_form_widget = None

        # retrieving widgets from xml
        self.xml = gtkgui_helpers.get_gtk_builder("adhoc_commands_window.ui")
        self.window = self.xml.get_object("adhoc_commands_window")
        self.window.connect("delete-event", self.on_adhoc_commands_window_delete_event)
        for name in (
            "restart_button",
            "back_button",
            "forward_button",
            "execute_button",
            "finish_button",
            "close_button",
            "stages_notebook",
            "retrieving_commands_stage_vbox",
            "command_list_stage_vbox",
            "command_list_vbox",
            "sending_form_stage_vbox",
            "sending_form_progressbar",
            "notes_label",
            "no_commands_stage_vbox",
            "error_stage_vbox",
            "error_description_label",
        ):
            setattr(self, name, self.xml.get_object(name))

        self.initiate()
Esempio n. 42
0
def get_contact_menu(contact, account, use_multiple_contacts=True,
show_start_chat=True, show_encryption=False, show_buttonbar_items=True,
control=None, gc_contact=None, is_anonymous=True):
    """
    Build contact popup menu for roster and chat window. If control is not set,
    we hide invite_contacts_menuitem
    """
    if not contact:
        return

    jid = contact.jid
    our_jid = jid == gajim.get_jid_from_account(account)
    roster = gajim.interface.roster

    xml = gtkgui_helpers.get_gtk_builder('contact_context_menu.ui')
    contact_context_menu = xml.get_object('contact_context_menu')

    start_chat_menuitem = xml.get_object('start_chat_menuitem')
    execute_command_menuitem = xml.get_object('execute_command_menuitem')
    rename_menuitem = xml.get_object('rename_menuitem')
    edit_groups_menuitem = xml.get_object('edit_groups_menuitem')
    send_file_menuitem = xml.get_object('send_file_menuitem')
    assign_openpgp_key_menuitem = xml.get_object('assign_openpgp_key_menuitem')
    add_special_notification_menuitem = xml.get_object(
            'add_special_notification_menuitem')
    information_menuitem = xml.get_object('information_menuitem')
    history_menuitem = xml.get_object('history_menuitem')
    send_custom_status_menuitem = xml.get_object('send_custom_status_menuitem')
    send_single_message_menuitem = xml.get_object('send_single_message_menuitem')
    invite_menuitem = xml.get_object('invite_menuitem')
    block_menuitem = xml.get_object('block_menuitem')
    unblock_menuitem = xml.get_object('unblock_menuitem')
    ignore_menuitem = xml.get_object('ignore_menuitem')
    unignore_menuitem = xml.get_object('unignore_menuitem')
    set_custom_avatar_menuitem = xml.get_object('set_custom_avatar_menuitem')
    # Subscription submenu
    subscription_menuitem = xml.get_object('subscription_menuitem')
    send_auth_menuitem, ask_auth_menuitem, revoke_auth_menuitem = \
            subscription_menuitem.get_submenu().get_children()
    add_to_roster_menuitem = xml.get_object('add_to_roster_menuitem')
    remove_from_roster_menuitem = xml.get_object(
            'remove_from_roster_menuitem')
    manage_contact_menuitem = xml.get_object('manage_contact')
    convert_to_gc_menuitem = xml.get_object('convert_to_groupchat_menuitem')
    encryption_separator = xml.get_object('encryption_separator')
    toggle_gpg_menuitem = xml.get_object('toggle_gpg_menuitem')
    toggle_e2e_menuitem = xml.get_object('toggle_e2e_menuitem')
    last_separator = xml.get_object('last_separator')

    items_to_hide = []

    contacts = gajim.contacts.get_contacts(account, jid)
    if len(contacts) > 1 and use_multiple_contacts: # several resources
        start_chat_menuitem.set_submenu(build_resources_submenu(contacts,
                account, gajim.interface.on_open_chat_window))
        send_file_menuitem.set_submenu(build_resources_submenu(contacts,
                account, roster.on_send_file_menuitem_activate, cap=NS_FILE))
        execute_command_menuitem.set_submenu(build_resources_submenu(
                contacts, account, roster.on_execute_command, cap=NS_COMMANDS))
    else:
        start_chat_menuitem.connect('activate',
                gajim.interface.on_open_chat_window, contact, account)
        if contact.supports(NS_FILE) or contact.supports(NS_JINGLE_FILE_TRANSFER):
            send_file_menuitem.set_sensitive(True)
            send_file_menuitem.connect('activate',
                    roster.on_send_file_menuitem_activate, contact, account)
        else:
            send_file_menuitem.set_sensitive(False)

        if contact.supports(NS_COMMANDS):
            execute_command_menuitem.set_sensitive(True)
            if gc_contact and gc_contact.jid and not is_anonymous:
                execute_command_menuitem.connect('activate',
                    roster.on_execute_command, gc_contact, account,
                    gc_contact.resource)
            else:
                execute_command_menuitem.connect('activate',
                    roster.on_execute_command, contact, account,
                    contact.resource)
        else:
            execute_command_menuitem.set_sensitive(False)

    rename_menuitem.connect('activate', roster.on_rename, 'contact', jid,
        account)
    history_menuitem.connect('activate', roster.on_history, contact, account)

    if control:
        convert_to_gc_menuitem.connect('activate',
            control._on_convert_to_gc_menuitem_activate)
    else:
        items_to_hide.append(convert_to_gc_menuitem)

    if _('Not in Roster') not in contact.get_shown_groups():
        # contact is in normal group
        edit_groups_menuitem.connect('activate', roster.on_edit_groups, [(contact,
                account)])

        if gajim.connections[account].gpg:
            assign_openpgp_key_menuitem.connect('activate',
                    roster.on_assign_pgp_key, contact, account)
        else:
            assign_openpgp_key_menuitem.set_sensitive(False)
    else:
        # contact is in group 'Not in Roster'
        edit_groups_menuitem.set_sensitive(False)
        assign_openpgp_key_menuitem.set_sensitive(False)

    # Hide items when it's self contact row
    if our_jid:
        items_to_hide += [rename_menuitem, edit_groups_menuitem]

    # Unsensitive many items when account is offline
    if gajim.account_is_disconnected(account):
        for widget in (start_chat_menuitem, rename_menuitem,
        edit_groups_menuitem, send_file_menuitem, convert_to_gc_menuitem,
        information_menuitem):
            widget.set_sensitive(False)

    if not show_start_chat:
        items_to_hide.append(start_chat_menuitem)

    if not show_encryption or not control:
        items_to_hide += [encryption_separator, toggle_gpg_menuitem,
                toggle_e2e_menuitem]
    else:
        e2e_is_active = control.session is not None and \
                control.session.enable_encryption

        # check if we support and use gpg
        if not gajim.config.get_per('accounts', account, 'keyid') or \
        not gajim.connections[account].USE_GPG or gajim.jid_is_transport(
        contact.jid):
            toggle_gpg_menuitem.set_sensitive(False)
        else:
            toggle_gpg_menuitem.set_sensitive(control.gpg_is_active or \
                    not e2e_is_active)
            toggle_gpg_menuitem.set_active(control.gpg_is_active)
            toggle_gpg_menuitem.connect('activate',
                    control._on_toggle_gpg_menuitem_activate)

        # disable esessions if we or the other client don't support them
        if not gajim.HAVE_PYCRYPTO or not contact.supports(NS_ESESSION) or \
        not gajim.config.get_per('accounts', account, 'enable_esessions'):
            toggle_e2e_menuitem.set_sensitive(False)
        else:
            toggle_e2e_menuitem.set_active(e2e_is_active)
            toggle_e2e_menuitem.set_sensitive(e2e_is_active or \
                    not control.gpg_is_active)
            toggle_e2e_menuitem.connect('activate',
                    control._on_toggle_e2e_menuitem_activate)

    if not show_buttonbar_items:
        items_to_hide += [history_menuitem, send_file_menuitem,
                information_menuitem, convert_to_gc_menuitem, last_separator]

    if not control:
        items_to_hide.append(convert_to_gc_menuitem)

    # Hide items when it's a pm
    if gc_contact:
        items_to_hide += [rename_menuitem, edit_groups_menuitem,
        subscription_menuitem, remove_from_roster_menuitem]

    for item in items_to_hide:
        item.set_no_show_all(True)
        item.hide()

    # Zeroconf Account
    if gajim.config.get_per('accounts', account, 'is_zeroconf'):
        for item in (send_custom_status_menuitem, send_single_message_menuitem,
        invite_menuitem, block_menuitem, unblock_menuitem, ignore_menuitem,
        unignore_menuitem, set_custom_avatar_menuitem, subscription_menuitem,
        manage_contact_menuitem, convert_to_gc_menuitem):
            item.set_no_show_all(True)
            item.hide()

        if contact.show in ('offline', 'error'):
            information_menuitem.set_sensitive(False)
            send_file_menuitem.set_sensitive(False)
        else:
            information_menuitem.connect('activate', roster.on_info_zeroconf,
                    contact, account)

        contact_context_menu.connect('selection-done',
                gtkgui_helpers.destroy_widget)
        contact_context_menu.show_all()
        return contact_context_menu

    # normal account

    # send custom status icon
    blocked = False
    if helpers.jid_is_blocked(account, jid):
        blocked = True
    else:
        for group in contact.get_shown_groups():
            if helpers.group_is_blocked(account, group):
                blocked = True
                break
    transport = gajim.get_transport_name_from_jid(jid, use_config_setting=False)
    if transport and transport != 'jabber':
        # Transport contact, send custom status unavailable
        send_custom_status_menuitem.set_sensitive(False)
    elif blocked:
        send_custom_status_menuitem.set_sensitive(False)

    if gc_contact:
        if not gc_contact.jid:
            # it's a pm and we don't know real JID
            invite_menuitem.set_sensitive(False)
        else:
            bookmarked = False
            c_ = gajim.contacts.get_contact(account, gc_contact.jid,
                gc_contact.resource)
            if c_ and c_.supports(NS_CONFERENCE):
                bookmarked=True
            build_invite_submenu(invite_menuitem, [(gc_contact, account)],
                show_bookmarked=bookmarked)
    else:
        force_resource = False
        if control and control.resource:
            force_resource = True
        build_invite_submenu(invite_menuitem, [(contact, account)],
            show_bookmarked=contact.supports(NS_CONFERENCE),
            force_resource=force_resource)

    if gajim.account_is_disconnected(account):
        invite_menuitem.set_sensitive(False)

    # One or several resource, we do the same for send_custom_status
    status_menuitems = Gtk.Menu()
    send_custom_status_menuitem.set_submenu(status_menuitems)
    for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
        # icon MUST be different instance for every item
        status_menuitem = Gtk.MenuItem.new_with_label(helpers.get_uf_show(s))
        status_menuitem.connect('activate', roster.on_send_custom_status,
                                [(contact, account)], s)
        status_menuitems.append(status_menuitem)

    send_single_message_menuitem.connect('activate',
        roster.on_send_single_message_menuitem_activate, account, contact)

    remove_from_roster_menuitem.connect('activate', roster.on_req_usub,
        [(contact, account)])
    information_menuitem.connect('activate', roster.on_info, contact, account)

    if _('Not in Roster') not in contact.get_shown_groups():
        # contact is in normal group
        add_to_roster_menuitem.hide()
        add_to_roster_menuitem.set_no_show_all(True)

        if contact.sub in ('from', 'both'):
            send_auth_menuitem.set_sensitive(False)
        else:
            send_auth_menuitem.connect('activate', roster.authorize, jid, account)
        if contact.sub in ('to', 'both'):
            ask_auth_menuitem.set_sensitive(False)
            add_special_notification_menuitem.connect('activate',
                    roster.on_add_special_notification_menuitem_activate, jid)
        else:
            ask_auth_menuitem.connect('activate', roster.req_sub, jid,
                    _('I would like to add you to my roster'), account,
                    contact.groups, contact.name)
        transport = gajim.get_transport_name_from_jid(jid,
            use_config_setting=False)
        if contact.sub in ('to', 'none') or transport not in ['jabber', None]:
            revoke_auth_menuitem.set_sensitive(False)
        else:
            revoke_auth_menuitem.connect('activate', roster.revoke_auth, jid,
                    account)

    elif gajim.connections[account].roster_supported:
        # contact is in group 'Not in Roster'
        add_to_roster_menuitem.set_no_show_all(False)
        subscription_menuitem.set_sensitive(False)

        add_to_roster_menuitem.connect('activate', roster.on_add_to_roster,
                contact, account)
    else:
        add_to_roster_menuitem.hide()
        add_to_roster_menuitem.set_no_show_all(True)
        subscription_menuitem.set_sensitive(False)

    set_custom_avatar_menuitem.connect('activate',
            roster.on_set_custom_avatar_activate, contact, account)

    # Hide items when it's self contact row
    if our_jid:
        manage_contact_menuitem.set_sensitive(False)

    # Unsensitive items when account is offline
    if gajim.account_is_disconnected(account):
        for widget in (send_single_message_menuitem, subscription_menuitem,
        add_to_roster_menuitem, remove_from_roster_menuitem,
        execute_command_menuitem, send_custom_status_menuitem):
            widget.set_sensitive(False)

    if gajim.connections[account] and (gajim.connections[account].\
    privacy_rules_supported or gajim.connections[account].blocking_supported):
        if helpers.jid_is_blocked(account, jid):
            block_menuitem.set_no_show_all(True)
            block_menuitem.hide()
            if gajim.get_transport_name_from_jid(jid, use_config_setting=False)\
            and transport != 'jabber':
                unblock_menuitem.set_no_show_all(True)
                unblock_menuitem.hide()
                unignore_menuitem.set_no_show_all(False)
                unignore_menuitem.connect('activate', roster.on_unblock, [(contact,
                        account)])
            else:
                unblock_menuitem.connect('activate', roster.on_unblock, [(contact,
                        account)])
        else:
            unblock_menuitem.set_no_show_all(True)
            unblock_menuitem.hide()
            if gajim.get_transport_name_from_jid(jid, use_config_setting=False)\
            and transport != 'jabber':
                block_menuitem.set_no_show_all(True)
                block_menuitem.hide()
                ignore_menuitem.set_no_show_all(False)
                ignore_menuitem.connect('activate', roster.on_block, [(contact,
                        account)])
            else:
                block_menuitem.connect('activate', roster.on_block, [(contact,
                        account)])
    else:
        unblock_menuitem.set_no_show_all(True)
        block_menuitem.set_sensitive(False)
        unblock_menuitem.hide()

    contact_context_menu.connect('selection-done', gtkgui_helpers.destroy_widget)
    contact_context_menu.show_all()
    return contact_context_menu
Esempio n. 43
0
    def __init__(self, acct, type_, parent_window=None, parent_paned=None):
        # A dictionary of dictionaries
        # where _contacts[account][jid] == A MessageControl
        self._controls = {}

        # If None, the window is not tied to any specific account
        self.account = acct
        # If None, the window is not tied to any specific type
        self.type_ = type_
        # dict { handler id: widget}. Keeps callbacks, which
        # lead to cylcular references
        self.handlers = {}
        # Don't show warning dialogs when we want to delete the window
        self.dont_warn_on_delete = False

        self.widget_name = 'message_window'
        self.xml = gtkgui_helpers.get_gtk_builder('%s.ui' % self.widget_name)
        self.window = self.xml.get_object(self.widget_name)
        self.notebook = self.xml.get_object('notebook')
        self.parent_paned = None

        if parent_window:
            orig_window = self.window
            self.window = parent_window
            self.parent_paned = parent_paned
            self.notebook.reparent(self.parent_paned)
            self.parent_paned.pack2(self.notebook, resize=True, shrink=True)
            gajim.interface.roster.xml.get_object('show_roster_menuitem').\
                set_sensitive(True)
            orig_window.destroy()
            del orig_window

        # NOTE: we use 'connect_after' here because in
        # MessageWindowMgr._new_window we register handler that saves window
        # state when closing it, and it should be called before
        # MessageWindow._on_window_delete, which manually destroys window
        # through win.destroy() - this means no additional handlers for
        # 'delete-event' are called.
        id_ = self.window.connect_after('delete-event', self._on_window_delete)
        self.handlers[id_] = self.window
        id_ = self.window.connect('destroy', self._on_window_destroy)
        self.handlers[id_] = self.window
        id_ = self.window.connect('focus-in-event', self._on_window_focus)
        self.handlers[id_] = self.window

        keys=['<Control>f', '<Control>g', '<Control>h', '<Control>i',
                '<Control>l', '<Control>L', '<Control><Shift>n', '<Control>u',
                '<Control>b', '<Control>F4',
                '<Control>w', '<Control>Page_Up', '<Control>Page_Down', '<Alt>Right',
                '<Alt>Left', '<Alt>d', '<Alt>c', '<Alt>m', '<Alt>t', 'Escape'] + \
                ['<Alt>'+str(i) for i in list(range(10))]
        accel_group = Gtk.AccelGroup()
        for key in keys:
            keyval, mod = Gtk.accelerator_parse(key)
            accel_group.connect(keyval, mod, Gtk.AccelFlags.VISIBLE,
                self.accel_group_func)
        self.window.add_accel_group(accel_group)

        # gtk+ doesn't make use of the motion notify on gtkwindow by default
        # so this line adds that
        self.window.add_events(Gdk.EventMask.POINTER_MOTION_MASK)

        id_ = self.notebook.connect('switch-page',
            self._on_notebook_switch_page)
        self.handlers[id_] = self.notebook
        id_ = self.notebook.connect('key-press-event',
            self._on_notebook_key_press)
        self.handlers[id_] = self.notebook

        # Tab customizations
        pref_pos = gajim.config.get('tabs_position')
        if pref_pos == 'bottom':
            nb_pos = Gtk.PositionType.BOTTOM
        elif pref_pos == 'left':
            nb_pos = Gtk.PositionType.LEFT
        elif pref_pos == 'right':
            nb_pos = Gtk.PositionType.RIGHT
        else:
            nb_pos = Gtk.PositionType.TOP
        self.notebook.set_tab_pos(nb_pos)
        window_mode = gajim.interface.msg_win_mgr.mode
        if gajim.config.get('tabs_always_visible') or \
        window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER:
            self.notebook.set_show_tabs(True)
        else:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(gajim.config.get('tabs_border'))
        self.show_icon()
Esempio n. 44
0
    def __init__(self, jid=None, account=None):
        xml = gtkgui_helpers.get_gtk_builder('history_window.ui')
        self.window = xml.get_object('history_window')
        self.calendar = xml.get_object('calendar')
        scrolledwindow = xml.get_object('scrolledwindow')
        self.history_textview = conversation_textview.ConversationTextview(
            account, used_in_history_window=True)
        scrolledwindow.add(self.history_textview.tv)
        self.history_buffer = self.history_textview.tv.get_buffer()
        self.history_buffer.create_tag('highlight', background='yellow')
        self.history_buffer.create_tag('invisible', invisible=True)
        self.checkbutton = xml.get_object('log_history_checkbutton')
        self.checkbutton.connect('toggled',
                                 self.on_log_history_checkbutton_toggled)
        self.show_status_checkbutton = xml.get_object(
            'show_status_checkbutton')
        self.search_entry = xml.get_object('search_entry')
        self.query_liststore = xml.get_object('query_liststore')
        self.jid_entry = xml.get_object('query_entry')
        self.jid_entry.connect('activate', self.on_jid_entry_activate)
        self.results_treeview = xml.get_object('results_treeview')
        self.results_window = xml.get_object('results_scrolledwindow')
        self.search_in_date = xml.get_object('search_in_date')

        # contact_name, date, message, time
        model = Gtk.ListStore(str, str, str, str, str)
        self.results_treeview.set_model(model)
        col = Gtk.TreeViewColumn(_('Name'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.CONTACT_NAME)
        col.set_sort_column_id(
            Column.CONTACT_NAME)  # user can click this header and sort
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Date'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.UNIXTIME)
        col.set_sort_column_id(
            Column.UNIXTIME)  # user can click this header and sort
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Message'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.MESSAGE)
        col.set_resizable(True)

        self.jid = None  # The history we are currently viewing
        self.account = None
        self.completion_dict = {}
        self.accounts_seen_online = []  # Update dict when new accounts connect
        self.jids_to_search = []

        # This will load history too
        task = self._fill_completion_dict()
        GLib.idle_add(next, task)

        if jid:
            self.jid_entry.set_text(jid)
        else:
            self._load_history(None)

        gtkgui_helpers.resize_window(self.window,
                                     gajim.config.get('history_window_width'),
                                     gajim.config.get('history_window_height'))
        gtkgui_helpers.move_window(
            self.window, gajim.config.get('history_window_x-position'),
            gajim.config.get('history_window_y-position'))

        xml.connect_signals(self)
        self.window.show_all()
Esempio n. 45
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_gtk_builder('features_window.ui')
        self.window = self.xml.get_object('features_window')
        self.window.set_transient_for(gajim.interface.roster.window)
        treeview = self.xml.get_object('features_treeview')
        self.desc_label = self.xml.get_object('feature_desc_label')

        # {name: (available_function, unix_text, windows_text)}
        self.features = {
            _('SSL certificate validation'): (self.pyopenssl_available,
                _('A library used to validate server certificates to ensure a secure connection.'),
                _('Requires python-pyopenssl > 0.12 and pyasn1.'),
                _('Requires python-pyopenssl > 0.12 and pyasn1.')),
            _('Bonjour / Zeroconf'): (self.zeroconf_available,
                _('Serverless chatting with autodetected clients in a local network.'),
                _('Requires python-avahi.'),
                _('Requires pybonjour and bonjour SDK running (http://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,
                _('Encrypting chat messages with OpenPGP keys.'),
                _('Requires gpg and python-gnupg (http://code.google.com/p/python-gnupg/).'),
                _('Requires gpg.exe in PATH.')),
            _('Network-manager'): (self.network_manager_available,
                _('Autodetection of network status.'),
                _('Requires gnome-network-manager and python-dbus.'),
                _('Feature not available under Windows.')),
            _('Session Management'): (self.session_management_available,
                _('Gajim session is stored on logout and restored on login.'),
                _('Requires python-gnome2.'),
                _('Feature not available under Windows.')),
            _('Password encryption'): (self.some_keyring_available,
                _('Passwords can be stored securely and not just in plaintext.'),
                _('Requires gnome-keyring and python-gnome2-desktop, or kwalletcli.'),
                _('Feature not available under Windows.')),
            _('SRV'): (self.srv_available,
                _('Ability to connect to servers which are using SRV records.'),
                _('Requires dnsutils.'),
                _('Requires nslookup to use SRV records.')),
            _('Spell Checker'): (self.speller_available,
                _('Spellchecking of composed messages.'),
                _('Requires libgtkspell.'),
                _('Requires libgtkspell and libenchant.')),
            _('Notification'): (self.notification_available,
                _('Passive popups notifying for new events.'),
                _('Requires python-notify or instead python-dbus in conjunction with notification-daemon.'),
                _('Feature not available under Windows.')),
            _('Automatic status'): (self.idle_available,
                _('Ability to measure idle time, in order to set auto status.'),
                _('Requires libxss library.'),
                _('Requires python2.5.')),
            _('End to End message encryption'): (self.pycrypto_available,
                _('Encrypting chat messages.'),
                _('Requires python-crypto.'),
                _('Requires python-crypto.')),
            _('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 python-farstream and gstreamer-plugins-bad.'),
                _('Feature not available under Windows.')),
            _('UPnP-IGD'): (self.gupnp_igd_available,
                _('Ability to request your router to forward port for file transfer.'),
                _('Requires python-gupnp-igd.'),
                _('Feature not available under Windows.')),
            _('UPower'): (self.upower_available,
                _('Ability to disconnect properly just before suspending the machine.'),
                _('Requires upower and python-dbus.'),
                _('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)
        col.set_attributes(cell, active = 1)

        col = gtk.TreeViewColumn(_('Feature'))
        treeview.append_column(col)
        cell = gtk.CellRendererText()
        col.pack_start(cell, expand = 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.SORT_ASCENDING)

        self.xml.connect_signals(self)
        self.window.show_all()
        self.xml.get_object('close_button').grab_focus()
Esempio n. 46
0
def get_contact_menu(contact,
                     account,
                     use_multiple_contacts=True,
                     show_start_chat=True,
                     show_encryption=False,
                     show_buttonbar_items=True,
                     control=None,
                     gc_contact=None,
                     is_anonymous=True):
    """
    Build contact popup menu for roster and chat window. If control is not set,
    we hide invite_contacts_menuitem
    """
    if not contact:
        return

    jid = contact.jid
    our_jid = jid == gajim.get_jid_from_account(account)
    roster = gajim.interface.roster

    xml = gtkgui_helpers.get_gtk_builder('contact_context_menu.ui')
    contact_context_menu = xml.get_object('contact_context_menu')

    start_chat_menuitem = xml.get_object('start_chat_menuitem')
    execute_command_menuitem = xml.get_object('execute_command_menuitem')
    rename_menuitem = xml.get_object('rename_menuitem')
    edit_groups_menuitem = xml.get_object('edit_groups_menuitem')
    send_file_menuitem = xml.get_object('send_file_menuitem')
    assign_openpgp_key_menuitem = xml.get_object('assign_openpgp_key_menuitem')
    add_special_notification_menuitem = xml.get_object(
        'add_special_notification_menuitem')
    information_menuitem = xml.get_object('information_menuitem')
    history_menuitem = xml.get_object('history_menuitem')
    send_custom_status_menuitem = xml.get_object('send_custom_status_menuitem')
    send_single_message_menuitem = xml.get_object(
        'send_single_message_menuitem')
    invite_menuitem = xml.get_object('invite_menuitem')
    block_menuitem = xml.get_object('block_menuitem')
    unblock_menuitem = xml.get_object('unblock_menuitem')
    ignore_menuitem = xml.get_object('ignore_menuitem')
    unignore_menuitem = xml.get_object('unignore_menuitem')
    set_custom_avatar_menuitem = xml.get_object('set_custom_avatar_menuitem')
    # Subscription submenu
    subscription_menuitem = xml.get_object('subscription_menuitem')
    send_auth_menuitem, ask_auth_menuitem, revoke_auth_menuitem = \
            subscription_menuitem.get_submenu().get_children()
    add_to_roster_menuitem = xml.get_object('add_to_roster_menuitem')
    remove_from_roster_menuitem = xml.get_object('remove_from_roster_menuitem')
    manage_contact_menuitem = xml.get_object('manage_contact')
    convert_to_gc_menuitem = xml.get_object('convert_to_groupchat_menuitem')
    encryption_separator = xml.get_object('encryption_separator')
    toggle_gpg_menuitem = xml.get_object('toggle_gpg_menuitem')
    toggle_e2e_menuitem = xml.get_object('toggle_e2e_menuitem')
    last_separator = xml.get_object('last_separator')

    items_to_hide = []

    contacts = gajim.contacts.get_contacts(account, jid)
    if len(contacts) > 1 and use_multiple_contacts:  # several resources
        start_chat_menuitem.set_submenu(
            build_resources_submenu(contacts, account,
                                    gajim.interface.on_open_chat_window))
        send_file_menuitem.set_submenu(
            build_resources_submenu(contacts,
                                    account,
                                    roster.on_send_file_menuitem_activate,
                                    cap=NS_FILE))
        execute_command_menuitem.set_submenu(
            build_resources_submenu(contacts,
                                    account,
                                    roster.on_execute_command,
                                    cap=NS_COMMANDS))
    else:
        start_chat_menuitem.connect('activate',
                                    gajim.interface.on_open_chat_window,
                                    contact, account)
        if contact.supports(NS_FILE) or contact.supports(
                NS_JINGLE_FILE_TRANSFER):
            send_file_menuitem.set_sensitive(True)
            send_file_menuitem.connect('activate',
                                       roster.on_send_file_menuitem_activate,
                                       contact, account)
        else:
            send_file_menuitem.set_sensitive(False)

        if contact.supports(NS_COMMANDS):
            execute_command_menuitem.set_sensitive(True)
            if gc_contact and gc_contact.jid and not is_anonymous:
                execute_command_menuitem.connect('activate',
                                                 roster.on_execute_command,
                                                 gc_contact, account,
                                                 gc_contact.resource)
            else:
                execute_command_menuitem.connect('activate',
                                                 roster.on_execute_command,
                                                 contact, account,
                                                 contact.resource)
        else:
            execute_command_menuitem.set_sensitive(False)

    rename_menuitem.connect('activate', roster.on_rename, 'contact', jid,
                            account)
    history_menuitem.connect('activate', roster.on_history, contact, account)

    if control:
        convert_to_gc_menuitem.connect(
            'activate', control._on_convert_to_gc_menuitem_activate)
    else:
        items_to_hide.append(convert_to_gc_menuitem)

    if _('Not in Roster') not in contact.get_shown_groups():
        # contact is in normal group
        edit_groups_menuitem.connect('activate', roster.on_edit_groups,
                                     [(contact, account)])

        if gajim.connections[account].gpg:
            assign_openpgp_key_menuitem.connect('activate',
                                                roster.on_assign_pgp_key,
                                                contact, account)
        else:
            assign_openpgp_key_menuitem.set_sensitive(False)
    else:
        # contact is in group 'Not in Roster'
        edit_groups_menuitem.set_sensitive(False)
        assign_openpgp_key_menuitem.set_sensitive(False)

    # Hide items when it's self contact row
    if our_jid:
        items_to_hide += [rename_menuitem, edit_groups_menuitem]

    # Unsensitive many items when account is offline
    if gajim.account_is_disconnected(account):
        for widget in (start_chat_menuitem, rename_menuitem,
                       edit_groups_menuitem, send_file_menuitem,
                       convert_to_gc_menuitem, information_menuitem):
            widget.set_sensitive(False)

    if not show_start_chat:
        items_to_hide.append(start_chat_menuitem)

    if not show_encryption or not control:
        items_to_hide += [
            encryption_separator, toggle_gpg_menuitem, toggle_e2e_menuitem
        ]
    else:
        e2e_is_active = control.session is not None and \
                control.session.enable_encryption

        # check if we support and use gpg
        if not gajim.config.get_per('accounts', account, 'keyid') or \
        not gajim.connections[account].USE_GPG or gajim.jid_is_transport(
        contact.jid):
            toggle_gpg_menuitem.set_sensitive(False)
        else:
            toggle_gpg_menuitem.set_sensitive(control.gpg_is_active or \
                    not e2e_is_active)
            toggle_gpg_menuitem.set_active(control.gpg_is_active)
            toggle_gpg_menuitem.connect(
                'activate', control._on_toggle_gpg_menuitem_activate)

        # disable esessions if we or the other client don't support them
        if not gajim.HAVE_PYCRYPTO or not contact.supports(NS_ESESSION) or \
        not gajim.config.get_per('accounts', account, 'enable_esessions'):
            toggle_e2e_menuitem.set_sensitive(False)
        else:
            toggle_e2e_menuitem.set_active(e2e_is_active)
            toggle_e2e_menuitem.set_sensitive(e2e_is_active or \
                    not control.gpg_is_active)
            toggle_e2e_menuitem.connect(
                'activate', control._on_toggle_e2e_menuitem_activate)

    if not show_buttonbar_items:
        items_to_hide += [
            history_menuitem, send_file_menuitem, information_menuitem,
            convert_to_gc_menuitem, last_separator
        ]

    if not control:
        items_to_hide.append(convert_to_gc_menuitem)

    # Hide items when it's a pm
    if gc_contact:
        items_to_hide += [
            rename_menuitem, edit_groups_menuitem, subscription_menuitem,
            remove_from_roster_menuitem
        ]

    for item in items_to_hide:
        item.set_no_show_all(True)
        item.hide()

    # Zeroconf Account
    if gajim.config.get_per('accounts', account, 'is_zeroconf'):
        for item in (send_custom_status_menuitem, send_single_message_menuitem,
                     invite_menuitem, block_menuitem, unblock_menuitem,
                     ignore_menuitem, unignore_menuitem,
                     set_custom_avatar_menuitem, subscription_menuitem,
                     manage_contact_menuitem, convert_to_gc_menuitem):
            item.set_no_show_all(True)
            item.hide()

        if contact.show in ('offline', 'error'):
            information_menuitem.set_sensitive(False)
            send_file_menuitem.set_sensitive(False)
        else:
            information_menuitem.connect('activate', roster.on_info_zeroconf,
                                         contact, account)

        contact_context_menu.connect('selection-done',
                                     gtkgui_helpers.destroy_widget)
        contact_context_menu.show_all()
        return contact_context_menu

    # normal account

    # send custom status icon
    blocked = False
    if helpers.jid_is_blocked(account, jid):
        blocked = True
    else:
        for group in contact.get_shown_groups():
            if helpers.group_is_blocked(account, group):
                blocked = True
                break
    transport = gajim.get_transport_name_from_jid(jid,
                                                  use_config_setting=False)
    if transport and transport != 'jabber':
        # Transport contact, send custom status unavailable
        send_custom_status_menuitem.set_sensitive(False)
    elif blocked:
        send_custom_status_menuitem.set_sensitive(False)

    if gc_contact:
        if not gc_contact.jid:
            # it's a pm and we don't know real JID
            invite_menuitem.set_sensitive(False)
        else:
            bookmarked = False
            c_ = gajim.contacts.get_contact(account, gc_contact.jid,
                                            gc_contact.resource)
            if c_ and c_.supports(NS_CONFERENCE):
                bookmarked = True
            build_invite_submenu(invite_menuitem, [(gc_contact, account)],
                                 show_bookmarked=bookmarked)
    else:
        force_resource = False
        if control and control.resource:
            force_resource = True
        build_invite_submenu(invite_menuitem, [(contact, account)],
                             show_bookmarked=contact.supports(NS_CONFERENCE),
                             force_resource=force_resource)

    if gajim.account_is_disconnected(account):
        invite_menuitem.set_sensitive(False)

    # One or several resource, we do the same for send_custom_status
    status_menuitems = Gtk.Menu()
    send_custom_status_menuitem.set_submenu(status_menuitems)
    for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'):
        # icon MUST be different instance for every item
        status_menuitem = Gtk.MenuItem.new_with_label(helpers.get_uf_show(s))
        status_menuitem.connect('activate', roster.on_send_custom_status,
                                [(contact, account)], s)
        status_menuitems.append(status_menuitem)

    send_single_message_menuitem.connect(
        'activate', roster.on_send_single_message_menuitem_activate, account,
        contact)

    remove_from_roster_menuitem.connect('activate', roster.on_req_usub,
                                        [(contact, account)])
    information_menuitem.connect('activate', roster.on_info, contact, account)

    if _('Not in Roster') not in contact.get_shown_groups():
        # contact is in normal group
        add_to_roster_menuitem.hide()
        add_to_roster_menuitem.set_no_show_all(True)

        if contact.sub in ('from', 'both'):
            send_auth_menuitem.set_sensitive(False)
        else:
            send_auth_menuitem.connect('activate', roster.authorize, jid,
                                       account)
        if contact.sub in ('to', 'both'):
            ask_auth_menuitem.set_sensitive(False)
            add_special_notification_menuitem.connect(
                'activate',
                roster.on_add_special_notification_menuitem_activate, jid)
        else:
            ask_auth_menuitem.connect(
                'activate', roster.req_sub, jid,
                _('I would like to add you to my roster'), account,
                contact.groups, contact.name)
        transport = gajim.get_transport_name_from_jid(jid,
                                                      use_config_setting=False)
        if contact.sub in ('to', 'none') or transport not in ['jabber', None]:
            revoke_auth_menuitem.set_sensitive(False)
        else:
            revoke_auth_menuitem.connect('activate', roster.revoke_auth, jid,
                                         account)

    elif gajim.connections[account].roster_supported:
        # contact is in group 'Not in Roster'
        add_to_roster_menuitem.set_no_show_all(False)
        subscription_menuitem.set_sensitive(False)

        add_to_roster_menuitem.connect('activate', roster.on_add_to_roster,
                                       contact, account)
    else:
        add_to_roster_menuitem.hide()
        add_to_roster_menuitem.set_no_show_all(True)
        subscription_menuitem.set_sensitive(False)

    set_custom_avatar_menuitem.connect('activate',
                                       roster.on_set_custom_avatar_activate,
                                       contact, account)

    # Hide items when it's self contact row
    if our_jid:
        manage_contact_menuitem.set_sensitive(False)

    # Unsensitive items when account is offline
    if gajim.account_is_disconnected(account):
        for widget in (send_single_message_menuitem, subscription_menuitem,
                       add_to_roster_menuitem, remove_from_roster_menuitem,
                       execute_command_menuitem, send_custom_status_menuitem):
            widget.set_sensitive(False)

    if gajim.connections[account] and (gajim.connections[account].\
    privacy_rules_supported or gajim.connections[account].blocking_supported):
        if helpers.jid_is_blocked(account, jid):
            block_menuitem.set_no_show_all(True)
            block_menuitem.hide()
            if gajim.get_transport_name_from_jid(jid, use_config_setting=False)\
            and transport != 'jabber':
                unblock_menuitem.set_no_show_all(True)
                unblock_menuitem.hide()
                unignore_menuitem.set_no_show_all(False)
                unignore_menuitem.connect('activate', roster.on_unblock,
                                          [(contact, account)])
            else:
                unblock_menuitem.connect('activate', roster.on_unblock,
                                         [(contact, account)])
        else:
            unblock_menuitem.set_no_show_all(True)
            unblock_menuitem.hide()
            if gajim.get_transport_name_from_jid(jid, use_config_setting=False)\
            and transport != 'jabber':
                block_menuitem.set_no_show_all(True)
                block_menuitem.hide()
                ignore_menuitem.set_no_show_all(False)
                ignore_menuitem.connect('activate', roster.on_block,
                                        [(contact, account)])
            else:
                block_menuitem.connect('activate', roster.on_block,
                                       [(contact, account)])
    else:
        unblock_menuitem.set_no_show_all(True)
        block_menuitem.set_sensitive(False)
        unblock_menuitem.hide()

    contact_context_menu.connect('selection-done',
                                 gtkgui_helpers.destroy_widget)
    contact_context_menu.show_all()
    return contact_context_menu
Esempio n. 47
0
    def __init__(self, jid = None, account = None):
        xml = gtkgui_helpers.get_gtk_builder('history_window.ui')
        self.window = xml.get_object('history_window')
        self.calendar = xml.get_object('calendar')
        scrolledwindow = xml.get_object('scrolledwindow')
        self.history_textview = conversation_textview.ConversationTextview(
            account, used_in_history_window = True)
        scrolledwindow.add(self.history_textview.tv)
        self.history_buffer = self.history_textview.tv.get_buffer()
        self.history_buffer.create_tag('highlight', background = 'yellow')
        self.history_buffer.create_tag('invisible', invisible=True)
        self.checkbutton = xml.get_object('log_history_checkbutton')
        self.checkbutton.connect('toggled',
            self.on_log_history_checkbutton_toggled)
        self.show_status_checkbutton = xml.get_object('show_status_checkbutton')
        self.search_entry = xml.get_object('search_entry')
        self.query_liststore = xml.get_object('query_liststore')
        self.jid_entry = xml.get_object('query_entry')
        self.jid_entry.connect('activate', self.on_jid_entry_activate)
        self.results_treeview = xml.get_object('results_treeview')
        self.results_window = xml.get_object('results_scrolledwindow')
        self.search_in_date = xml.get_object('search_in_date')

        # contact_name, date, message, time
        model = Gtk.ListStore(str, str, str, str, str)
        self.results_treeview.set_model(model)
        col = Gtk.TreeViewColumn(_('Name'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', C_CONTACT_NAME)
        col.set_sort_column_id(C_CONTACT_NAME) # user can click this header and sort
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Date'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', C_UNIXTIME)
        col.set_sort_column_id(C_UNIXTIME) # user can click this header and sort
        col.set_resizable(True)

        col = Gtk.TreeViewColumn(_('Message'))
        self.results_treeview.append_column(col)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', C_MESSAGE)
        col.set_resizable(True)

        self.jid = None # The history we are currently viewing
        self.account = None
        self.completion_dict = {}
        self.accounts_seen_online = [] # Update dict when new accounts connect
        self.jids_to_search = []

        # This will load history too
        task = self._fill_completion_dict()
        GLib.idle_add(next, task)

        if jid:
            self.jid_entry.set_text(jid)
        else:
            self._load_history(None)

        gtkgui_helpers.resize_window(self.window,
                gajim.config.get('history_window_width'),
                gajim.config.get('history_window_height'))
        gtkgui_helpers.move_window(self.window,
                gajim.config.get('history_window_x-position'),
                gajim.config.get('history_window_y-position'))

        xml.connect_signals(self)
        self.window.show_all()
    def __init__(self):
        self.xml = gtkgui_helpers.get_gtk_builder('advanced_configuration_window.ui')
        self.window = self.xml.get_object('advanced_configuration_window')
        self.window.set_transient_for(
                gajim.interface.instances['preferences'].window)
        self.entry = self.xml.get_object('advanced_entry')
        self.desc_label = self.xml.get_object('advanced_desc_label')
        self.restart_label = self.xml.get_object('restart_label')
        self.reset_button = self.xml.get_object('reset_button')

        # 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': _('Boolean'),
                'integer': _('Integer'),
                'string': _('Text'),
                'color': _('Color')}

        treeview = self.xml.get_object('advanced_treeview')
        self.treeview = treeview
        self.model = gtk.TreeStore(str, str, str)
        self.fill_model()
        self.model.set_sort_column_id(0, gtk.SORT_ASCENDING)
        self.modelfilter = self.model.filter_new()
        self.modelfilter.set_visible_func(self.visible_func)

        renderer_text = gtk.CellRendererText()
        col = treeview.insert_column_with_attributes(-1, _('Preference Name'),
                renderer_text, text = 0)
        col.set_resizable(True)

        renderer_text = gtk.CellRendererText()
        renderer_text.connect('edited', self.on_config_edited)
        renderer_text.set_property("ellipsize", pango.ELLIPSIZE_END)
        col = treeview.insert_column_with_attributes(-1, _('Value'),
                renderer_text, text = 1)
        col.set_cell_data_func(renderer_text, self.cb_value_column_data)

        col.props.resizable = True
        col.set_property('expand',True)
        col.set_property('sizing',gtk.TREE_VIEW_COLUMN_FIXED)

        renderer_text = gtk.CellRendererText()
        col = treeview.insert_column_with_attributes(-1, _('Type'),
                renderer_text, text = 2)
        col.set_property('expand',True)
        col.set_property('sizing',gtk.TREE_VIEW_COLUMN_FIXED)

        treeview.set_model(self.modelfilter)

        # connect signal for selection change
        treeview.get_selection().connect('changed',
                self.on_advanced_treeview_selection_changed)

        self.xml.connect_signals(self)
        self.window.show_all()
        self.restart_label.hide()
        gajim.interface.instances['advanced_config'] = self
Esempio n. 49
0
    def __init__(self):
        self.files_props = {'r' : {}, 's': {}}
        self.height_diff = 0
        self.xml = gtkgui_helpers.get_gtk_builder('filetransfers.ui')
        self.window = self.xml.get_object('file_transfers_window')
        self.tree = self.xml.get_object('transfers_list')
        self.cancel_button = self.xml.get_object('cancel_button')
        self.pause_button = self.xml.get_object('pause_restore_button')
        self.cleanup_button = self.xml.get_object('cleanup_button')
        self.notify_ft_checkbox = self.xml.get_object(
                'notify_ft_complete_checkbox')

        shall_notify = gajim.config.get('notify_on_file_complete')
        self.notify_ft_checkbox.set_active(shall_notify
                                                                                                )
        self.model = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str, int,
            int, str)
        self.tree.set_model(self.model)
        col = Gtk.TreeViewColumn()

        render_pixbuf = Gtk.CellRendererPixbuf()

        col.pack_start(render_pixbuf, True)
        render_pixbuf.set_property('xpad', 3)
        render_pixbuf.set_property('ypad', 3)
        render_pixbuf.set_property('yalign', .0)
        col.add_attribute(render_pixbuf, 'pixbuf', 0)
        self.tree.append_column(col)

        col = Gtk.TreeViewColumn(_('File'))
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, False)
        col.add_attribute(renderer, 'markup', C_LABELS)
        renderer.set_property('yalign', 0.)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'markup', C_FILE)
        renderer.set_property('xalign', 0.)
        renderer.set_property('yalign', 0.)
        renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        col.set_resizable(True)
        col.set_expand(True)
        self.tree.append_column(col)

        col = Gtk.TreeViewColumn(_('Time'))
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, False)
        col.add_attribute(renderer, 'markup', C_TIME)
        renderer.set_property('yalign', 0.5)
        renderer.set_property('xalign', 0.5)
        renderer = Gtk.CellRendererText()
        renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        col.set_resizable(True)
        col.set_expand(False)
        self.tree.append_column(col)

        col = Gtk.TreeViewColumn(_('Progress'))
        renderer = Gtk.CellRendererProgress()
        renderer.set_property('yalign', 0.5)
        renderer.set_property('xalign', 0.5)
        col.pack_start(renderer, False)
        col.add_attribute(renderer, 'text', C_PROGRESS)
        col.add_attribute(renderer, 'value', C_PERCENT)
        col.add_attribute(renderer, 'pulse', C_PULSE)
        col.set_resizable(True)
        col.set_expand(False)
        self.tree.append_column(col)

        self.images = {}
        self.icons = {
                'upload': Gtk.STOCK_GO_UP,
                'download': Gtk.STOCK_GO_DOWN,
                'stop': Gtk.STOCK_STOP,
                'waiting': Gtk.STOCK_REFRESH,
                'pause': Gtk.STOCK_MEDIA_PAUSE,
                'continue': Gtk.STOCK_MEDIA_PLAY,
                'ok': Gtk.STOCK_APPLY,
                'computing': Gtk.STOCK_EXECUTE,
                'hash_error': Gtk.STOCK_STOP,
        }

        self.tree.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
        self.tree.get_selection().connect('changed', self.selection_changed)
        self.tooltip = tooltips.FileTransfersTooltip()
        self.file_transfers_menu = self.xml.get_object('file_transfers_menu')
        self.open_folder_menuitem = self.xml.get_object('open_folder_menuitem')
        self.cancel_menuitem = self.xml.get_object('cancel_menuitem')
        self.pause_menuitem = self.xml.get_object('pause_menuitem')
        self.continue_menuitem = self.xml.get_object('continue_menuitem')
        self.remove_menuitem = self.xml.get_object('remove_menuitem')
        self.xml.connect_signals(self)
Esempio n. 50
0
    def __init__(self, dataform, selectable=False):
        assert isinstance(dataform, dataforms.SimpleDataForm)

        gtk.Table.__init__(self)
        self.set_col_spacings(12)
        self.set_row_spacings(6)

        def decorate_with_tooltip(widget, field):
            """
            Adds a tooltip containing field's description to a widget.  Creates
            EventBox if widget doesn't have its own gdk window.  Returns decorated
            widget
            """
            if field.description != '':
                if widget.flags() & gtk.NO_WINDOW:
                    evbox = gtk.EventBox()
                    evbox.add(widget)
                    widget = evbox
                widget.set_tooltip_text(field.description)
            return widget

        self._data_form = dataform

        # building widget
        linecounter = 0

        # is the form changeable?
        readwrite = dataform.type_ != 'result'

        # for each field...
        for field in self._data_form.iter_fields():
            if field.type_ == 'hidden': continue

            commonlabel = True
            commonlabelcenter = False
            commonwidget = True
            widget = None

            if field.type_ == 'boolean':
                commonlabelcenter = True
                widget = gtk.CheckButton()
                widget.connect('toggled', self.on_boolean_checkbutton_toggled,
                        field)
                widget.set_active(field.value)

            elif field.type_ == 'fixed':
                leftattach = 1
                rightattach = 2
                if field.label is None:
                    commonlabel = False
                    leftattach = 0

                commonwidget = False
                widget = gtk.Label(field.value)
                widget.set_property('selectable', selectable)
                widget.set_line_wrap(True)
                self.attach(widget, leftattach, rightattach, linecounter,
                        linecounter+1, xoptions=gtk.FILL, yoptions=gtk.FILL)

            elif field.type_ == 'list-single':
                # TODO: What if we have radio buttons and non-required field?
                # TODO: We cannot deactivate them all...
                if len(field.options) < 6:
                    # 5 option max: show radiobutton
                    widget = gtk.VBox()
                    first_radio = None
                    for value, label in field.iter_options():
                        if not label:
                            label = value
                        radio = gtk.RadioButton(first_radio, label=label)
                        radio.connect('toggled',
                                self.on_list_single_radiobutton_toggled, field, value)
                        if first_radio is None:
                            first_radio = radio
                            if field.value == '':   # TODO: is None when done
                                field.value = value
                        if value == field.value:
                            radio.set_active(True)
                        widget.pack_start(radio, expand=False)
                else:
                    # more than 5 options: show combobox
                    def on_list_single_combobox_changed(combobox, f):
                        iter_ = combobox.get_active_iter()
                        if iter_:
                            model = combobox.get_model()
                            f.value = model[iter_][1]
                        else:
                            f.value = ''
                    widget = gtkgui_helpers.create_combobox(field.options,
                            field.value)
                    widget.connect('changed', on_list_single_combobox_changed, field)
                widget.set_sensitive(readwrite)

            elif field.type_ == 'list-multi':
                # TODO: When more than few choices, make a list
                if len(field.options) < 6:
                    # 5 option max: show checkbutton
                    widget = gtk.VBox()
                    for value, label in field.iter_options():
                        check = gtk.CheckButton(label, use_underline=False)
                        check.set_active(value in field.values)
                        check.connect('toggled',
                                self.on_list_multi_checkbutton_toggled, field, value)
                        widget.pack_start(check, expand=False)
                        widget.set_sensitive(readwrite)
                else:
                    # more than 5 options: show combobox
                    def on_list_multi_treeview_changed(selection, f):
                        def for_selected(treemodel, path, iter):
                            vals.append(treemodel[iter][1])
                        vals = []
                        selection.selected_foreach(for_selected)
                        field.values = vals[:]
                    widget = gtk.ScrolledWindow()
                    widget.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
                    tv = gtkgui_helpers.create_list_multi(field.options,
                            field.values)
                    widget.add(tv)
                    widget.set_size_request(-1, 120)
                    tv.get_selection().connect('changed',
                            on_list_multi_treeview_changed, field)
                    tv.set_sensitive(readwrite)

            elif field.type_ == 'jid-single':
                widget = gtk.Entry()
                widget.connect('changed', self.on_text_single_entry_changed, field)
                widget.set_text(field.value)

            elif field.type_ == 'jid-multi':
                commonwidget = False

                xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
                    'multiple_form_hbox')
                widget = xml.get_object('multiple_form_hbox')
                treeview = xml.get_object('records_treeview')

                listmodel = gtk.ListStore(str)
                for value in field.iter_values():
                    # nobody will create several megabytes long stanza
                    listmodel.insert(999999, (value,))

                treeview.set_model(listmodel)

                renderer = gtk.CellRendererText()
                renderer.set_property('editable', True)
                renderer.connect('edited',
                        self.on_jid_multi_cellrenderertext_edited, treeview, listmodel,
                        field)

                treeview.append_column(gtk.TreeViewColumn(None, renderer,
                        text=0))

                decorate_with_tooltip(treeview, field)

                add_button=xml.get_object('add_button')
                add_button.connect('clicked',
                        self.on_jid_multi_add_button_clicked, treeview, listmodel, field)
                edit_button=xml.get_object('edit_button')
                edit_button.connect('clicked',
                        self.on_jid_multi_edit_button_clicked, treeview)
                remove_button=xml.get_object('remove_button')
                remove_button.connect('clicked',
                        self.on_jid_multi_remove_button_clicked, treeview, field)
                clear_button=xml.get_object('clear_button')
                clear_button.connect('clicked',
                        self.on_jid_multi_clean_button_clicked, listmodel, field)
                if not readwrite:
                    add_button.set_no_show_all(True)
                    edit_button.set_no_show_all(True)
                    remove_button.set_no_show_all(True)
                    clear_button.set_no_show_all(True)

                widget.set_sensitive(readwrite)
                self.attach(widget, 1, 2, linecounter, linecounter+1)

                del xml

            elif field.type_ == 'text-private':
                commonlabelcenter = True
                widget = gtk.Entry()
                widget.connect('changed', self.on_text_single_entry_changed, field)
                widget.set_visibility(False)
                widget.set_text(field.value)

            elif field.type_ == 'text-multi':
                # TODO: bigger text view
                commonwidget = False

                textwidget = gtk.TextView()
                textwidget.set_wrap_mode(gtk.WRAP_WORD)
                textwidget.get_buffer().connect('changed',
                        self.on_text_multi_textbuffer_changed, field)
                textwidget.get_buffer().set_text(field.value)
                if readwrite:
                    textwidget.set_sensitive(True)
                else:
                    if selectable:
                        textwidget.set_editable(True)
                    else:
                        textwidget.set_sensitive(False)

                widget = gtk.ScrolledWindow()
                widget.add(textwidget)

                widget=decorate_with_tooltip(widget, field)
                self.attach(widget, 1, 2, linecounter, linecounter+1)

            else:
                # field.type_ == 'text-single' or field.type_ is nonstandard:
                # JEP says that if we don't understand some type, we
                # should handle it as text-single
                commonlabelcenter = True
                if readwrite:
                    widget = gtk.Entry()
                    def kpe(widget, event):
                        if event.keyval == gtk.keysyms.Return or \
                        event.keyval == gtk.keysyms.KP_Enter:
                            self.emit('validated')
                    widget.connect('key-press-event', kpe)
                    widget.connect('changed', self.on_text_single_entry_changed,
                            field)
                    widget.set_sensitive(readwrite)
                    if field.value is None:
                        field.value = u''
                    widget.set_text(field.value)
                else:
                    commonwidget=False
                    widget = gtk.Label(field.value)
                    widget.set_property('selectable', selectable)
                    widget.set_sensitive(True)
                    widget.set_alignment(0.0, 0.5)
                    widget=decorate_with_tooltip(widget, field)
                    self.attach(widget, 1, 2, linecounter, linecounter+1,
                            yoptions=gtk.FILL)

            if commonlabel and field.label is not None:
                label = gtk.Label(field.label)
                if commonlabelcenter:
                    label.set_alignment(0.0, 0.5)
                else:
                    label.set_alignment(0.0, 0.0)
                label = decorate_with_tooltip(label, field)
                self.attach(label, 0, 1, linecounter, linecounter+1,
                        xoptions=gtk.FILL, yoptions=gtk.FILL)

            if field.media is not None:
                for uri in field.media.uris:
                    if uri.type_.startswith('image/'):
                        try:
                            img_data = base64.decodestring(uri.uri_data)
                            pixbuf_l = gtk.gdk.PixbufLoader()
                            pixbuf_l.write(img_data)
                            pixbuf_l.close()
                            media = gtk.image_new_from_pixbuf(pixbuf_l.\
                                get_pixbuf())
                        except Exception:
                            media = gtk.Label(_('Unable to load image'))
                    else:
                        media = gtk.Label(_('Media type not supported: %s') % \
                            uri.type_)
                    linecounter += 1
                    self.attach(media, 0, 1, linecounter, linecounter+1,
                        xoptions=gtk.FILL, yoptions=gtk.FILL)

            if commonwidget:
                assert widget is not None
                widget.set_sensitive(readwrite)
                widget = decorate_with_tooltip(widget, field)
                self.attach(widget, 1, 2, linecounter, linecounter+1,
                        yoptions=gtk.FILL)

            if field.required:
                label = gtk.Label('*')
                label.set_tooltip_text(_('This field is required'))
                self.attach(label, 2, 3, linecounter, linecounter+1, xoptions=0,
                    yoptions=0)

            linecounter+=1
        if self.get_property('visible'):
            self.show_all()
Esempio n. 51
0
    def __init__(self, dataform, selectable=False):
        assert isinstance(dataform, dataforms.SimpleDataForm)

        GObject.GObject.__init__(self)
        self.set_col_spacings(12)
        self.set_row_spacings(6)

        def decorate_with_tooltip(widget, field):
            """
            Adds a tooltip containing field's description to a widget.  Creates
            EventBox if widget doesn't have its own gdk window.  Returns decorated
            widget
            """
            if field.description != '':
                if not widget.get_window():
                    #if widget.flags() & Gtk.NO_WINDOW:
                    evbox = Gtk.EventBox()
                    evbox.add(widget)
                    widget = evbox
                widget.set_tooltip_text(field.description)
            return widget

        self._data_form = dataform

        # building widget
        linecounter = 0

        # is the form changeable?
        readwrite = dataform.type_ != 'result'

        # for each field...
        for field in self._data_form.iter_fields():
            if field.type_ == 'hidden': continue

            commonlabel = True
            commonlabelcenter = False
            commonwidget = True
            widget = None

            if field.type_ == 'boolean':
                commonlabelcenter = True
                widget = Gtk.CheckButton()
                widget.connect('toggled', self.on_boolean_checkbutton_toggled,
                               field)
                widget.set_active(field.value)

            elif field.type_ == 'fixed':
                leftattach = 1
                rightattach = 2
                if field.label is None:
                    commonlabel = False
                    leftattach = 0

                commonwidget = False
                widget = Gtk.Label(label=field.value)
                widget.set_property('selectable', selectable)
                widget.set_line_wrap(True)
                self.attach(widget,
                            leftattach,
                            rightattach,
                            linecounter,
                            linecounter + 1,
                            xoptions=Gtk.AttachOptions.FILL,
                            yoptions=Gtk.AttachOptions.FILL)

            elif field.type_ == 'list-single':
                # TODO: What if we have radio buttons and non-required field?
                # TODO: We cannot deactivate them all...
                if len(field.options) < 6:
                    # 5 option max: show radiobutton
                    widget = Gtk.VBox()
                    first_radio = None
                    for value, label in field.iter_options():
                        if not label:
                            label = value
                        radio = Gtk.RadioButton.new_with_label_from_widget(
                            first_radio, label)
                        radio.connect('toggled',
                                      self.on_list_single_radiobutton_toggled,
                                      field, value)
                        if first_radio is None:
                            first_radio = radio
                            if field.value == '':  # TODO: is None when done
                                field.value = value
                        if value == field.value:
                            radio.set_active(True)
                        widget.pack_start(radio, False, True, 0)
                else:
                    # more than 5 options: show combobox
                    def on_list_single_combobox_changed(combobox, f):
                        iter_ = combobox.get_active_iter()
                        if iter_:
                            model = combobox.get_model()
                            f.value = model[iter_][1]
                        else:
                            f.value = ''

                    widget = gtkgui_helpers.create_combobox(
                        field.options, field.value)
                    widget.connect('changed', on_list_single_combobox_changed,
                                   field)
                widget.set_sensitive(readwrite)

            elif field.type_ == 'list-multi':
                # TODO: When more than few choices, make a list
                if len(field.options) < 6:
                    # 5 option max: show checkbutton
                    widget = Gtk.VBox()
                    for value, label in field.iter_options():
                        check = Gtk.CheckButton(label=label,
                                                use_underline=False)
                        check.set_active(value in field.values)
                        check.connect('toggled',
                                      self.on_list_multi_checkbutton_toggled,
                                      field, value)
                        widget.pack_start(check, False, True, 0)
                        widget.set_sensitive(readwrite)
                else:
                    # more than 5 options: show combobox
                    def on_list_multi_treeview_changed(selection, f):
                        def for_selected(treemodel, path, iter):
                            vals.append(treemodel[iter][1])

                        vals = []
                        selection.selected_foreach(for_selected)
                        field.values = vals[:]

                    widget = Gtk.ScrolledWindow()
                    widget.set_policy(Gtk.PolicyType.AUTOMATIC,
                                      Gtk.PolicyType.AUTOMATIC)
                    tv = gtkgui_helpers.create_list_multi(
                        field.options, field.values)
                    widget.add(tv)
                    widget.set_size_request(-1, 120)
                    tv.get_selection().connect('changed',
                                               on_list_multi_treeview_changed,
                                               field)
                    tv.set_sensitive(readwrite)

            elif field.type_ == 'jid-single':
                widget = Gtk.Entry()
                widget.connect('changed', self.on_text_single_entry_changed,
                               field)
                widget.set_text(field.value)

            elif field.type_ == 'jid-multi':
                commonwidget = False

                xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
                                                     'multiple_form_hbox')
                widget = xml.get_object('multiple_form_hbox')
                treeview = xml.get_object('records_treeview')

                listmodel = Gtk.ListStore(str)
                for value in field.iter_values():
                    # nobody will create several megabytes long stanza
                    listmodel.insert(999999, (value, ))

                treeview.set_model(listmodel)

                renderer = Gtk.CellRendererText()
                renderer.set_property('editable', True)
                renderer.connect('edited',
                                 self.on_jid_multi_cellrenderertext_edited,
                                 treeview, listmodel, field)

                treeview.append_column(
                    Gtk.TreeViewColumn(None, renderer, text=0))

                decorate_with_tooltip(treeview, field)

                add_button = xml.get_object('add_button')
                add_button.connect('clicked',
                                   self.on_jid_multi_add_button_clicked,
                                   treeview, listmodel, field)
                edit_button = xml.get_object('edit_button')
                edit_button.connect('clicked',
                                    self.on_jid_multi_edit_button_clicked,
                                    treeview)
                remove_button = xml.get_object('remove_button')
                remove_button.connect('clicked',
                                      self.on_jid_multi_remove_button_clicked,
                                      treeview, field)
                clear_button = xml.get_object('clear_button')
                clear_button.connect('clicked',
                                     self.on_jid_multi_clean_button_clicked,
                                     listmodel, field)
                if not readwrite:
                    add_button.set_no_show_all(True)
                    edit_button.set_no_show_all(True)
                    remove_button.set_no_show_all(True)
                    clear_button.set_no_show_all(True)

                widget.set_sensitive(readwrite)
                self.attach(widget, 1, 2, linecounter, linecounter + 1)

                del xml

            elif field.type_ == 'text-private':
                commonlabelcenter = True
                widget = Gtk.Entry()
                widget.connect('changed', self.on_text_single_entry_changed,
                               field)
                widget.set_visibility(False)
                widget.set_text(field.value)

            elif field.type_ == 'text-multi':
                # TODO: bigger text view
                commonwidget = False

                textwidget = Gtk.TextView()
                textwidget.set_wrap_mode(Gtk.WrapMode.WORD)
                textwidget.get_buffer().connect(
                    'changed', self.on_text_multi_textbuffer_changed, field)
                textwidget.get_buffer().set_text(field.value)
                if readwrite:
                    textwidget.set_sensitive(True)
                else:
                    if selectable:
                        textwidget.set_editable(True)
                    else:
                        textwidget.set_sensitive(False)

                widget = Gtk.ScrolledWindow()
                widget.add(textwidget)

                widget = decorate_with_tooltip(widget, field)
                self.attach(widget, 1, 2, linecounter, linecounter + 1)

            else:
                # field.type_ == 'text-single' or field.type_ is nonstandard:
                # JEP says that if we don't understand some type, we
                # should handle it as text-single
                commonlabelcenter = True
                if readwrite:
                    widget = Gtk.Entry()

                    def kpe(widget, event):
                        if event.keyval == Gdk.KEY_Return or \
                        event.keyval == Gdk.KEY_KP_Enter:
                            self.emit('validated')

                    widget.connect('key-press-event', kpe)
                    widget.connect('changed',
                                   self.on_text_single_entry_changed, field)
                    widget.set_sensitive(readwrite)
                    if field.value is None:
                        field.value = ''
                    widget.set_text(field.value)
                else:
                    commonwidget = False
                    widget = Gtk.Label(label=field.value)
                    widget.set_property('selectable', selectable)
                    widget.set_sensitive(True)
                    widget.set_halign(Gtk.Align.START)
                    widget.set_valign(Gtk.Align.CENTER)
                    widget = decorate_with_tooltip(widget, field)
                    self.attach(widget,
                                1,
                                2,
                                linecounter,
                                linecounter + 1,
                                yoptions=Gtk.AttachOptions.FILL)

            if commonlabel and field.label is not None:
                label = Gtk.Label(label=field.label)
                if commonlabelcenter:
                    label.set_halign(Gtk.Align.START)
                    label.set_valign(Gtk.Align.CENTER)
                else:
                    label.set_halign(Gtk.Align.START)
                    label.set_valign(Gtk.Align.START)
                label = decorate_with_tooltip(label, field)
                self.attach(label,
                            0,
                            1,
                            linecounter,
                            linecounter + 1,
                            xoptions=Gtk.AttachOptions.FILL,
                            yoptions=Gtk.AttachOptions.FILL)

            if field.media is not None:
                for uri in field.media.uris:
                    if uri.type_.startswith('image/'):
                        try:
                            img_data = base64.b64decode(uri.uri_data)
                            pixbuf_l = GdkPixbuf.PixbufLoader()
                            pixbuf_l.write(img_data)
                            pixbuf_l.close()
                            media = Gtk.Image.new_from_pixbuf(pixbuf_l.\
                                get_pixbuf())
                        except Exception:
                            media = Gtk.Label(label=_('Unable to load image'))
                    else:
                        media = Gtk.Label(label=_('Media type not supported: %s') % \
                            uri.type_)
                    linecounter += 1
                    self.attach(media,
                                0,
                                1,
                                linecounter,
                                linecounter + 1,
                                xoptions=Gtk.AttachOptions.FILL,
                                yoptions=Gtk.AttachOptions.FILL)

            if commonwidget:
                assert widget is not None
                widget.set_sensitive(readwrite)
                widget = decorate_with_tooltip(widget, field)
                self.attach(widget,
                            1,
                            2,
                            linecounter,
                            linecounter + 1,
                            yoptions=Gtk.AttachOptions.FILL)

            if field.required:
                label = Gtk.Label(label='*')
                label.set_tooltip_text(_('This field is required'))
                self.attach(label,
                            2,
                            3,
                            linecounter,
                            linecounter + 1,
                            xoptions=0,
                            yoptions=0)

            linecounter += 1
        if self.get_property('visible'):
            self.show_all()
Esempio n. 52
0
    def __init__(self):
        self.files_props = {'r' : {}, 's': {}}
        self.height_diff = 0
        self.xml = gtkgui_helpers.get_gtk_builder('filetransfers.ui')
        self.window = self.xml.get_object('file_transfers_window')
        self.tree = self.xml.get_object('transfers_list')
        self.cancel_button = self.xml.get_object('cancel_button')
        self.pause_button = self.xml.get_object('pause_restore_button')
        self.cleanup_button = self.xml.get_object('cleanup_button')
        self.notify_ft_checkbox = self.xml.get_object(
                'notify_ft_complete_checkbox')

        shall_notify = gajim.config.get('notify_on_file_complete')
        self.notify_ft_checkbox.set_active(shall_notify
                                                                                                )
        self.model = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, str, str, int,
            int, str)
        self.tree.set_model(self.model)
        col = Gtk.TreeViewColumn()

        render_pixbuf = Gtk.CellRendererPixbuf()

        col.pack_start(render_pixbuf, True)
        render_pixbuf.set_property('xpad', 3)
        render_pixbuf.set_property('ypad', 3)
        render_pixbuf.set_property('yalign', .0)
        col.add_attribute(render_pixbuf, 'pixbuf', 0)
        self.tree.append_column(col)

        col = Gtk.TreeViewColumn(_('File'))
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, False)
        col.add_attribute(renderer, 'markup', Column.LABELS)
        renderer.set_property('yalign', 0.)
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'markup', Column.FILE)
        renderer.set_property('xalign', 0.)
        renderer.set_property('yalign', 0.)
        renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        col.set_resizable(True)
        col.set_expand(True)
        self.tree.append_column(col)

        col = Gtk.TreeViewColumn(_('Time'))
        renderer = Gtk.CellRendererText()
        col.pack_start(renderer, False)
        col.add_attribute(renderer, 'markup', Column.TIME)
        renderer.set_property('yalign', 0.5)
        renderer.set_property('xalign', 0.5)
        renderer = Gtk.CellRendererText()
        renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
        col.set_resizable(True)
        col.set_expand(False)
        self.tree.append_column(col)

        col = Gtk.TreeViewColumn(_('Progress'))
        renderer = Gtk.CellRendererProgress()
        renderer.set_property('yalign', 0.5)
        renderer.set_property('xalign', 0.5)
        col.pack_start(renderer, False)
        col.add_attribute(renderer, 'text', Column.PROGRESS)
        col.add_attribute(renderer, 'value', Column.PERCENT)
        col.add_attribute(renderer, 'pulse', Column.PULSE)
        col.set_resizable(True)
        col.set_expand(False)
        self.tree.append_column(col)

        self.images = {}
        self.icons = {
                'upload': Gtk.STOCK_GO_UP,
                'download': Gtk.STOCK_GO_DOWN,
                'stop': Gtk.STOCK_STOP,
                'waiting': Gtk.STOCK_REFRESH,
                'pause': Gtk.STOCK_MEDIA_PAUSE,
                'continue': Gtk.STOCK_MEDIA_PLAY,
                'ok': Gtk.STOCK_APPLY,
                'computing': Gtk.STOCK_EXECUTE,
                'hash_error': Gtk.STOCK_STOP,
        }

        self.tree.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
        self.tree.get_selection().connect('changed', self.selection_changed)
        self.tooltip = tooltips.FileTransfersTooltip()
        self.file_transfers_menu = self.xml.get_object('file_transfers_menu')
        self.open_folder_menuitem = self.xml.get_object('open_folder_menuitem')
        self.cancel_menuitem = self.xml.get_object('cancel_menuitem')
        self.pause_menuitem = self.xml.get_object('pause_menuitem')
        self.continue_menuitem = self.xml.get_object('continue_menuitem')
        self.remove_menuitem = self.xml.get_object('remove_menuitem')
        self.xml.connect_signals(self)
Esempio n. 53
0
    def __init__(self, contact, account, gc_contact=None):
        # the contact variable is the jid if vcard is true
        self.xml = gtkgui_helpers.get_gtk_builder(
            'vcard_information_window.ui')
        self.window = self.xml.get_object('vcard_information_window')
        self.progressbar = self.xml.get_object('progressbar')

        self.contact = contact
        self.account = account
        self.gc_contact = gc_contact

        # Get real jid
        if gc_contact:
            # Don't use real jid if room is (semi-)anonymous
            gc_control = gajim.interface.msg_win_mgr.get_gc_control(
                gc_contact.room_jid, account)
            if gc_contact.jid and not gc_control.is_anonymous:
                self.real_jid = gc_contact.jid
                self.real_jid_for_vcard = gc_contact.jid
                if gc_contact.resource:
                    self.real_jid += '/' + gc_contact.resource
            else:
                self.real_jid = gc_contact.get_full_jid()
                self.real_jid_for_vcard = self.real_jid
            self.real_resource = gc_contact.name
        else:
            self.real_jid = contact.get_full_jid()
            self.real_resource = contact.resource

        puny_jid = helpers.sanitize_filename(contact.jid)
        local_avatar_basepath = os.path.join(gajim.AVATAR_PATH, puny_jid) + \
                '_local'
        for extension in ('.png', '.jpeg'):
            local_avatar_path = local_avatar_basepath + extension
            if os.path.isfile(local_avatar_path):
                image = self.xml.get_object('custom_avatar_image')
                image.set_from_file(local_avatar_path)
                image.show()
                self.xml.get_object('custom_avatar_label').show()
                break
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.vcard_arrived = False
        self.os_info_arrived = False
        self.entity_time_arrived = False
        self.time = 0
        self.update_intervall = 100  # Milliseconds
        self.update_progressbar_timeout_id = GLib.timeout_add(
            self.update_intervall, self.update_progressbar)

        gajim.ged.register_event_handler('version-result-received', ged.GUI1,
                                         self.set_os_info)
        gajim.ged.register_event_handler('last-result-received', ged.GUI2,
                                         self.set_last_status_time)
        gajim.ged.register_event_handler('time-result-received', ged.GUI1,
                                         self.set_entity_time)
        gajim.ged.register_event_handler('vcard-received', ged.GUI1,
                                         self._nec_vcard_received)

        self.fill_jabber_page()
        annotations = gajim.connections[self.account].annotations
        if self.contact.jid in annotations:
            buffer_ = self.xml.get_object('textview_annotation').get_buffer()
            buffer_.set_text(annotations[self.contact.jid])

        style_provider = Gtk.CssProvider()
        css = 'GtkButton { padding-left: 5px; border-left: none; }'
        style_provider.load_from_data(css.encode())
        for widget_name in ('URL_label', 'EMAIL_WORK_USERID_label',
                            'EMAIL_HOME_USERID_label'):
            widget = self.xml.get_object(widget_name)
            context = widget.get_style_context()
            context.add_provider(style_provider,
                                 Gtk.STYLE_PROVIDER_PRIORITY_USER)
            widget.hide()

        self.xml.connect_signals(self)
        self.xml.get_object('close_button').grab_focus()
        self.window.show_all()
Esempio n. 54
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_gtk_builder(
            'advanced_configuration_window.ui')
        self.window = self.xml.get_object('advanced_configuration_window')
        self.window.set_transient_for(
            gajim.interface.instances['preferences'].window)
        self.entry = self.xml.get_object('advanced_entry')
        self.desc_label = self.xml.get_object('advanced_desc_label')
        self.restart_box = self.xml.get_object('restart_box')
        self.reset_button = self.xml.get_object('reset_button')

        # 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': _('Boolean'),
            'integer': _('Integer'),
            'string': _('Text'),
            'color': _('Color')
        }

        treeview = self.xml.get_object('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()
        col = Gtk.TreeViewColumn(_('Preference Name'), renderer_text, text=0)
        treeview.insert_column(col, -1)
        col.set_resizable(True)

        renderer_text = Gtk.CellRendererText()
        renderer_text.connect('edited', self.on_config_edited)
        renderer_text.set_property('ellipsize', Pango.EllipsizeMode.END)
        col = Gtk.TreeViewColumn(_('Value'), renderer_text, text=1)
        treeview.insert_column(col, -1)
        col.set_cell_data_func(renderer_text, self.cb_value_column_data)

        col.props.resizable = True
        col.props.expand = True
        col.props.sizing = Gtk.TreeViewColumnSizing.FIXED

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

        treeview.set_model(self.modelfilter)

        # connect signal for selection change
        treeview.get_selection().connect(
            'changed', self.on_advanced_treeview_selection_changed)

        self.xml.connect_signals(self)
        self.restart_box.set_no_show_all(True)
        self.window.show_all()
        gajim.interface.instances['advanced_config'] = self
Esempio n. 55
0
    def __init__(self):
        '''Initialize Plugins window'''
        self.xml = gtkgui_helpers.get_gtk_builder('plugins_window.ui')
        self.window = self.xml.get_object('plugins_window')
        self.window.set_transient_for(gajim.interface.roster.window)

        widgets_to_extract = ('plugins_notebook', 'plugin_name_label',
                              'plugin_version_label', 'plugin_authors_label',
                              'plugin_homepage_linkbutton',
                              'uninstall_plugin_button',
                              'configure_plugin_button',
                              'installed_plugins_treeview')

        for widget_name in widgets_to_extract:
            setattr(self, widget_name, self.xml.get_object(widget_name))

        self.plugin_description_textview = HtmlTextView()
        sw = self.xml.get_object('scrolledwindow2')
        sw.add(self.plugin_description_textview)
        self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
                                                     GdkPixbuf.Pixbuf)
        self.installed_plugins_treeview.set_model(self.installed_plugins_model)
        self.installed_plugins_treeview.set_rules_hint(True)

        renderer = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(_('Plugin'))  #, renderer, text=NAME)
        cell = Gtk.CellRendererPixbuf()
        col.pack_start(cell, False)
        col.add_attribute(cell, 'pixbuf', ICON)
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', NAME)
        col.set_property('expand', True)
        self.installed_plugins_treeview.append_column(col)

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self.installed_plugins_toggled_cb)
        col = Gtk.TreeViewColumn(_('Active'),
                                 renderer,
                                 active=ACTIVE,
                                 activatable=ACTIVATABLE)
        self.installed_plugins_treeview.append_column(col)

        self.def_icon = gtkgui_helpers.get_icon_pixmap('preferences-desktop')

        # connect signal for selection change
        selection = self.installed_plugins_treeview.get_selection()
        selection.connect('changed',
                          self.installed_plugins_treeview_selection_changed)
        selection.set_mode(Gtk.SelectionMode.SINGLE)

        self._clear_installed_plugin_info()

        self.fill_installed_plugins_model()
        root_iter = self.installed_plugins_model.get_iter_first()
        if root_iter:
            selection.select_iter(root_iter)

        self.xml.connect_signals(self)

        self.plugins_notebook.set_current_page(0)
        self.xml.get_object('close_button').grab_focus()

        self.window.show_all()
        gtkgui_helpers.possibly_move_window_in_current_desktop(self.window)
Esempio n. 56
0
    def __init__(self):
        self.xml = gtkgui_helpers.get_gtk_builder('features_window.ui')
        self.window = self.xml.get_object('features_window')
        self.window.set_transient_for(gajim.interface.roster.window)
        treeview = self.xml.get_object('features_treeview')
        self.desc_label = self.xml.get_object('feature_desc_label')

        # {name: (available_function, unix_text, windows_text)}
        self.features = {
            _('SSL certificate validation'):
            (self.pyopenssl_available,
             _('A library used to validate server certificates to ensure a secure connection.'
               ), _('Requires python-pyopenssl > 0.12 and pyasn1.'),
             _('Requires python-pyopenssl > 0.12 and pyasn1.')),
            _('Bonjour / Zeroconf'):
            (self.zeroconf_available,
             _('Serverless chatting with autodetected clients in a local network.'
               ), _('Requires python-avahi.'),
             _('Requires pybonjour and bonjour SDK running (http://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 (http://code.google.com/p/python-gnupg/).'
               ), _('Requires gpg.exe in PATH.')),
            _('Network-manager'):
            (self.network_manager_available,
             _('Autodetection of network status.'),
             _('Requires gnome-network-manager and python-dbus.'),
             _('Feature not available under Windows.')),
            _('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 libgtkspell.'),
                                 _('Requires libgtkspell and libenchant.')),
            _('Notification'):
            (self.notification_available,
             _('Passive popups notifying for new events.'),
             _('Requires python-notify or instead python-dbus in conjunction with notification-daemon.'
               ), _('Feature not available under Windows.')),
            _('Automatic status'):
            (self.idle_available,
             _('Ability to measure idle time, in order to set auto status.'),
             _('Requires libxss library.'), _('Requires python2.5.')),
            _('End to End message encryption'):
            (self.pycrypto_available, _('Encrypting chat messages.'),
             _('Requires python-crypto.'), _('Requires python-crypto.')),
            _('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 python-gupnp-igd.'),
             _('Feature not available under Windows.')),
            _('UPower'):
            (self.upower_available,
             _('Ability to disconnect properly just before suspending the machine.'
               ), _('Requires upower and python-dbus.'),
             _('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.xml.connect_signals(self)
        self.window.show_all()
        self.xml.get_object('close_button').grab_focus()