Ejemplo n.º 1
0
    def _startup(self, application):

        # Create and initialize Application Paths & Databases
        app.detect_dependencies()
        configpaths.create_paths()
        try:
            app.logger = logger.Logger()
            caps_cache.initialize(app.logger)
        except exceptions.DatabaseMalformed as error:
            dlg = Gtk.MessageDialog(
                None,
                Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
                Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _('Database Error'))
            dlg.format_secondary_text(str(error))
            dlg.run()
            dlg.destroy()
            sys.exit()

        # Set Application Menu
        app.app = self
        from gajim import gtkgui_helpers
        builder = gtkgui_helpers.get_gtk_builder('application_menu.ui')
        menubar = builder.get_object("menubar")
        appmenu = builder.get_object("appmenu")
        if app.prefers_app_menu():
            self.set_app_menu(appmenu)
        else:
            # Add it to the menubar instead
            menubar.prepend_submenu('Gajim', appmenu)
        self.set_menubar(menubar)
Ejemplo n.º 2
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

        app.ged.register_event_handler('search-form-received', ged.GUI1,
                                       self._nec_search_form_received)
        app.ged.register_event_handler('search-result-received', ged.GUI1,
                                       self._nec_search_result_received)
Ejemplo n.º 3
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 = app.get_jid_from_account(account)

        self.dialog = None
        self.avatar_mime_type = None
        self.avatar_encoded = None
        self.avatar_sha = 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)
        app.ged.register_event_handler('vcard-published', ged.GUI1,
                                       self._nec_vcard_published)
        app.ged.register_event_handler('vcard-not-published', ged.GUI1,
                                       self._nec_vcard_not_published)
        self.window.show_all()
        self.xml.get_object('ok_button').grab_focus()
        app.connections[account].request_vcard(self._nec_vcard_received,
                                               self.jid)
Ejemplo n.º 4
0
    def __init__(self, send_callback, transient_for):
        active_window = app.app.get_active_window()
        Gtk.ApplicationWindow.__init__(self)
        self.set_name('SendFileDialog')
        self.set_application(app.app)
        self.set_show_menubar(False)
        self.set_resizable(True)
        self.set_default_size(400, 250)
        self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
        self.set_transient_for(active_window)
        self.set_title(_('Choose a File to Send…'))
        self.set_destroy_with_parent(True)

        self._send_callback = send_callback

        xml = gtkgui_helpers.get_gtk_builder('send_file_dialog.ui')
        grid = xml.get_object('send_file_grid')

        self._filebox = xml.get_object('listbox')
        self._description = xml.get_object('description')

        self.add(grid)
        self.connect('key-press-event', self._key_press_event)

        xml.connect_signals(self)
        self.show_all()
Ejemplo n.º 5
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.resource = resource
        # control_id is a unique id for the control,
        # its used as action name for actions that belong to a control
        self.control_id = str(uuid.uuid4())
        self.session = None

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

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

        app.ged.register_event_handler('message-outgoing', ged.OUT_GUI1,
                                       self._nec_message_outgoing)
Ejemplo n.º 6
0
    def __init__(self, account, jid, commandnode=None):
        """
        Create new window
        """

        # an account object
        self.account = app.connections[account]
        self.jid = jid
        self.commandnode = commandnode
        self.data_form_widget = None
        self.stage_finish_cb = None
        self.stage_back_button_cb = None
        self.stage_forward_button_cb = None
        self.stage_execute_button_cb = None
        self.stage_close_button_cb = None
        self.stage_restart_button_cb = None
        self.stage_window_delete_cb = 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()
Ejemplo n.º 7
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.clean_cb = None

        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)
Ejemplo n.º 8
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.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_since_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()
Ejemplo n.º 9
0
    def __init__(self, transient):
        self._builder = gtkgui_helpers.get_gtk_builder(
            'manage_sounds_window.ui')
        self.window = self._builder.get_object('manage_sounds_window')
        self.window.set_transient_for(transient)

        self.sound_button = self._builder.get_object('filechooser')

        filter_ = Gtk.FileFilter()
        filter_.set_name(_('All files'))
        filter_.add_pattern('*')
        self.sound_button.add_filter(filter_)

        filter_ = Gtk.FileFilter()
        filter_.set_name(_('Wav Sounds'))
        filter_.add_pattern('*.wav')
        self.sound_button.add_filter(filter_)
        self.sound_button.set_filter(filter_)

        self.sound_tree = self._builder.get_object('sounds_treeview')

        self._fill_sound_treeview()

        self._builder.connect_signals(self)

        self.window.show_all()
Ejemplo n.º 10
0
    def __init__(self):
        self.contact = None

        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))
Ejemplo n.º 11
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()
Ejemplo n.º 12
0
    def make_link_menu(self, event, kind, text):
        from gajim.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')

            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 app.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)
Ejemplo n.º 13
0
 def __init__(self, account):
     self.account = account
     xml = gtkgui_helpers.get_gtk_builder('remove_account_window.ui')
     self.window = xml.get_object('remove_account_window')
     active_window = app.app.get_active_window()
     self.window.set_transient_for(active_window)
     self.remove_and_unregister_radiobutton = xml.get_object(
             'remove_and_unregister_radiobutton')
     self.window.set_title(_('Removing %s account') % self.account)
     xml.connect_signals(self)
     self.window.show_all()
Ejemplo n.º 14
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
Ejemplo n.º 15
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()
Ejemplo n.º 16
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.fill_contact_page()
        self.fill_personal_page()

        self.xml.connect_signals(self)
        self.window.show_all()
Ejemplo n.º 17
0
    def __init__(self, transient_for=None):
        self.xml = gtkgui_helpers.get_gtk_builder('manage_proxies_window.ui')
        self.window = self.xml.get_object('manage_proxies_window')
        self.window.set_transient_for(transient_for)
        self.proxies_treeview = self.xml.get_object('proxies_treeview')
        self.proxyname_entry = self.xml.get_object('proxyname_entry')
        self.proxytype_combobox = self.xml.get_object('proxytype_combobox')

        self.init_list()
        self.block_signal = False
        self.xml.connect_signals(self)
        self.window.show_all()
        # hide the BOSH fields by default
        self.show_bosh_fields()
Ejemplo n.º 18
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(
            app.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 = app.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()
Ejemplo n.º 19
0
    def __init__(self, account, jid, commandnode=None):
        """
        Create new window
        """

        # an account object
        self._con = app.connections[account]
        self.jid = jid
        self.commandnode = commandnode
        self.data_form_widget = None
        self.stage_finish_cb = None
        self.stage_back_button_cb = None
        self.stage_forward_button_cb = None
        self.stage_execute_button_cb = None
        self.stage_close_button_cb = None
        self.stage_restart_button_cb = None
        self.stage_window_delete_cb = 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',
                     'retrieving_commands_spinner', 'command_list_stage_vbox',
                     'command_treeview', 'sending_form_stage_vbox',
                     'sending_form_spinner', 'notes_label',
                     'no_commands_stage_vbox', 'error_stage_vbox',
                     'error_description_label'):
            setattr(self, name, self.xml.get_object(name))

        self.command_store = Gtk.ListStore(str, str)
        self.command_treeview.set_model(self.command_store)
        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn("Command", renderer, text=0)
        self.command_treeview.append_column(column)

        app.ged.register_event_handler('adhoc-command-error', ged.CORE,
                                       self._on_command_error)
        app.ged.register_event_handler('adhoc-command-list', ged.CORE,
                                       self._on_command_list)
        app.ged.register_event_handler('adhoc-command-action-response',
                                       ged.CORE, self._on_action_response)

        self.initiate()
Ejemplo n.º 20
0
    def __init__(self):
        pixs = []
        for size in (16, 32, 48, 64, 128):
            pix = gtkgui_helpers.get_icon_pixmap('org.gajim.Gajim', size)
            if pix:
                pixs.append(pix)
        if pixs:
            # set the icon to all windows
            Gtk.Window.set_default_icon_list(pixs)

        log_db_path = configpaths.get('LOG_DB')
        if not os.path.exists(log_db_path):
            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 = sqlite3.connect(
            log_db_path, timeout=20.0, isolation_level='IMMEDIATE')
        self.con.execute("PRAGMA secure_delete=1")
        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)
Ejemplo n.º 21
0
    def __init__(self, account, parent):
        Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP, transient_for=parent)
        self.account = account
        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()
Ejemplo n.º 22
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()
Ejemplo n.º 23
0
    def __init__(self):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_show_menubar(False)
        self.set_name('AccountsWindow')
        self.set_size_request(500, -1)
        self.set_resizable(False)
        self.need_relogin = {}

        glade_objects = [
            'stack', 'box', 'actionbar', 'headerbar', 'back_button',
            'menu_button', 'account_page', 'account_list'
        ]
        self.builder = gtkgui_helpers.get_gtk_builder('accounts_window.ui')
        for obj in glade_objects:
            setattr(self, obj, self.builder.get_object(obj))

        self.set_titlebar(self.headerbar)

        menu = Gio.Menu()
        menu.append(_('Merge Accounts'), 'app.merge')
        menu.append(_('Use PGP Agent'), 'app.agent')
        self.menu_button.set_menu_model(menu)

        button = get_image_button('list-add-symbolic', _('Add'))
        button.set_action_name('app.add-account')
        self.actionbar.pack_start(button)

        accounts = app.config.get_per('accounts')
        accounts.sort()
        for account in accounts:
            self.need_relogin[account] = self.get_relogin_options(account)
            account_item = Account(account, self)
            self.account_list.add(account_item)
            account_item.set_activatable()

        self.add(self.box)
        self.builder.connect_signals(self)

        self.connect('destroy', self.on_destroy)
        self.connect('key-press-event', self.on_key_press)
        self.show_all()
Ejemplo n.º 24
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()
Ejemplo n.º 25
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(app.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()
Ejemplo n.º 26
0
    def __init__(self):
        Gtk.ApplicationWindow.__init__(self)
        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_show_menubar(False)
        self.set_name('AccountsWindow')
        self.set_default_size(700, 550)
        self.set_resizable(False)
        self.set_title(_('Accounts'))
        self.need_relogin = {}

        glade_objects = ['stack', 'box', 'account_list']
        self.builder = gtkgui_helpers.get_gtk_builder('accounts_window.ui')
        for obj in glade_objects:
            setattr(self, obj, self.builder.get_object(obj))

        self.account_list.add(Preferences(self))
        account_item = AddAccount()
        self.account_list.add(account_item)
        account_item.set_activatable()

        accounts = app.config.get_per('accounts')
        accounts.sort()
        for account in accounts:
            self.need_relogin[account] = self.get_relogin_options(account)
            account_item = Account(account, self)
            self.account_list.add(account_item)
            account_item.set_activatable()

        self.add(self.box)
        self.builder.connect_signals(self)

        self.connect('destroy', self.on_destroy)
        self.connect('key-press-event', self.on_key_press)

        self._activate_preferences_page()
        self.show_all()

        app.ged.register_event_handler('our-show', ged.GUI2,
                                       self._nec_our_status)
Ejemplo n.º 27
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)
Ejemplo n.º 28
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()
Ejemplo n.º 29
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 = app.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': 'go-up',
            'download': 'go-down',
            'stop': 'window-close',
            'waiting': 'view-refresh',
            'pause': 'media-playback-pause',
            'continue': 'media-playback-start',
            'ok': 'emblem-ok-symbolic',
            'computing': 'system-run',
            'hash_error': 'network-error-symbolic',
        }

        self.tree.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
        self.tree.get_selection().connect('changed', self.selection_changed)

        # Tooltip
        self.tree.connect('query-tooltip', self._query_tooltip)
        self.tree.set_has_tooltip(True)
        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)
Ejemplo n.º 30
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(
            app.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()
        app.interface.instances['advanced_config'] = self