def __init__(self, account): # 'account' can be None if we are about to create our first one if not app.account_is_available(account): ErrorDialog( _('You are not connected to the server'), _('Without a connection, you can not synchronise your contacts.' )) raise GajimGeneralException('You are not connected to the server') self.account = account self.xml = get_builder('synchronise_select_account_dialog.ui') self.dialog = self.xml.get_object('synchronise_select_account_dialog') self.dialog.set_transient_for(get_app_window('AccountsWindow')) self.accounts_treeview = self.xml.get_object('accounts_treeview') model = Gtk.ListStore(str, str, bool) self.accounts_treeview.set_model(model) # columns renderer = Gtk.CellRendererText() self.accounts_treeview.insert_column_with_attributes(-1, _('Name'), renderer, text=0) renderer = Gtk.CellRendererText() self.accounts_treeview.insert_column_with_attributes(-1, _('Server'), renderer, text=1) self.xml.connect_signals(self) self.init_accounts() self.dialog.show_all()
def __init__(self, list_): """ list_ is a list of (contact, account) tuples """ self.xml = get_builder('edit_groups_dialog.ui') self.dialog = self.xml.get_object('edit_groups_dialog') self.dialog.set_transient_for(app.interface.roster.window) self.list_ = list_ self.changes_made = False self.treeview = self.xml.get_object('groups_treeview') if len(list_) == 1: contact = list_[0][0] self.xml.get_object('nickname_label').set_markup( _('Contact name: <i>%s</i>') % contact.get_shown_name()) self.xml.get_object('jid_label').set_markup( _('XMPP Address: <i>%s</i>') % contact.jid) else: self.xml.get_object('nickname_label').set_no_show_all(True) self.xml.get_object('nickname_label').hide() self.xml.get_object('jid_label').set_no_show_all(True) self.xml.get_object('jid_label').hide() self.xml.connect_signals(self) self.init_list() self.dialog.show_all() if self.changes_made: for (contact, account) in self.list_: con = app.connections[account] con.get_module('Roster').update_contact( contact.jid, contact.name, contact.groups)
def __init__(self, account, remote_account): self.local_account = account self.remote_account = remote_account self.xml = get_builder('synchronise_select_contacts_dialog.ui') self.dialog = self.xml.get_object('synchronise_select_contacts_dialog') self.contacts_treeview = self.xml.get_object('contacts_treeview') model = Gtk.ListStore(bool, str) self.contacts_treeview.set_model(model) # columns renderer1 = Gtk.CellRendererToggle() renderer1.set_property('activatable', True) renderer1.connect('toggled', self.toggled_callback) self.contacts_treeview.insert_column_with_attributes(-1, _('Synchronise'), renderer1, active=0) renderer2 = Gtk.CellRendererText() self.contacts_treeview.insert_column_with_attributes(-1, _('Name'), renderer2, text=1) self.xml.connect_signals(self) self.init_contacts() self.dialog.show_all()
def __init__(self): log_db_path = configpaths.get('LOG_DB') if not log_db_path.exists(): ErrorDialog(_('Cannot find history logs database'), _('%s does not exist.') % log_db_path) sys.exit() self._ui = get_builder('history_manager.ui') Gtk.Window.set_default_icon_list(get_app_icon_list( self._ui.history_manager_window)) 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._ui.search_entry.grab_focus() self._ui.history_manager_window.show_all() self._ui.connect_signals(self)
def on_listview_button_press_event(self, widget, event): if event.button == 3: # right click _ui = get_builder('history_manager.ui', ['context_menu']) if Gtk.Buildable.get_name(widget) != 'jids_listview': _ui.export_menuitem.hide() _ui.delete_menuitem.connect('activate', self.on_delete_menuitem_activate, widget) _ui.connect_signals(self) _ui.context_menu.popup(None, None, None, None, event.button, event.time) return True
def __init__(self, contact, account, is_fake=False): # the contact variable is the jid if vcard is true self.xml = get_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()
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: first_widget = self.notebook.get_nth_page(0) ctrl = self._widget_to_control(first_widget) self.notebook.set_show_tabs(True) ctrl.scroll_to_end() # Add notebook page and connect up to the tab's close button xml = get_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 position = self.notebook.get_current_page() + 1 self.notebook.insert_page(control.widget, tab_label_box, position) 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() if self.get_num_controls() == 1: GLib.timeout_add(500, control.focus)
def __init__(self, account, *args): Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) self.set_show_menubar(False) self.set_type_hint(Gdk.WindowTypeHint.DIALOG) self.set_resizable(True) self.set_default_size(700, 600) self.set_name('ProfileWindow') self.set_title(_('Profile')) self.account = account self._jid = app.get_jid_from_account(account) self._ui = get_builder('profile.ui') menu = Gio.Menu() for action, label in MENU_DICT.items(): menu.append(label, 'win.add-' + action.lower()) self._ui.add_entry_button.set_menu_model(menu) self._add_actions() self._avatar_selector = None self._current_avatar = None self._current_vcard = None self._avatar_nick_public = None # False - no change to avatar # None - we want to delete the avatar # Avatar - upload new avatar self._new_avatar = False self._ui.nickname_entry.set_text(app.nicks[account]) self._vcard_grid = VCardGrid(self.account) self._ui.profile_box.add(self._vcard_grid) self.add(self._ui.profile_stack) self.show_all() self._load_avatar() client = app.get_client(account) client.get_module('VCard4').request_vcard( callback=self._on_vcard_received) client.get_module('PubSub').get_access_model( Namespace.VCARD4_PUBSUB, callback=self._on_access_model_received, user_data=Namespace.VCARD4_PUBSUB) client.get_module('PubSub').get_access_model( Namespace.AVATAR_METADATA, callback=self._on_access_model_received, user_data=Namespace.AVATAR_METADATA) client.get_module('PubSub').get_access_model( Namespace.AVATAR_DATA, callback=self._on_access_model_received, user_data=Namespace.AVATAR_DATA) client.get_module('PubSub').get_access_model( Namespace.NICK, callback=self._on_access_model_received, user_data=Namespace.NICK) self._ui.connect_signals(self) self.connect('key-press-event', self._on_key_press_event)
def __init__(self, account, jids, preselected=None): """ This window is used to transform a one-to-one chat to a MUC. We do 2 things: first select the server and then make a guests list """ self.instances.append(self) self.account = account self.auto_jids = jids self.preselected_jids = preselected self.xml = get_builder('chat_to_muc_window.ui') self.window = self.xml.get_object('chat_to_muc_window') for widget_to_add in ('invite_button', 'cancel_button', 'server_list_comboboxentry', 'guests_treeview', 'guests_store', 'server_and_guests_hseparator', 'server_select_label'): self.__dict__[widget_to_add] = self.xml.get_object(widget_to_add) server_list = [] self.servers = Gtk.ListStore(str) self.server_list_comboboxentry.set_model(self.servers) cell = Gtk.CellRendererText() self.server_list_comboboxentry.pack_start(cell, True) self.server_list_comboboxentry.add_attribute(cell, 'text', 0) # get the muc server of our server con = app.connections[account] service_jid = con.get_module('MUC').service_jid if service_jid is not None: server_list.append(str(service_jid)) # add servers or recently joined groupchats recently_groupchat = app.settings.get_account_setting( account, 'recent_groupchats').split() for g in recently_groupchat: server = app.get_server_from_jid(g) if server not in server_list and not server.startswith('irc'): server_list.append(server) # add a default server if not server_list: server_list.append('conference.jabber.org') for s in server_list: self.servers.append([s]) self.server_list_comboboxentry.set_active(0) # set treeview # name, jid self.guests_store.set_sort_column_id(1, Gtk.SortType.ASCENDING) self.guests_treeview.get_selection().set_mode( Gtk.SelectionMode.MULTIPLE) # All contacts beside the following can be invited: # transports, zeroconf contacts, minimized groupchats def invitable(contact, contact_transport=None): return (contact.jid not in self.auto_jids and contact.jid != app.get_jid_from_account(account) and contact.jid not in app.interface.minimized_controls[account] and not contact.is_transport() and contact_transport in ('jabber', None)) # set jabber id and pseudos for account_ in app.contacts.get_accounts(): if app.connections[account_].is_zeroconf: continue for jid in app.contacts.get_jid_list(account_): contact = app.contacts.get_contact_with_highest_priority( account_, jid) contact_transport = app.get_transport_name_from_jid(jid) # Add contact if it can be invited if invitable(contact, contact_transport) and \ contact.show not in ('offline', 'error'): icon_name = get_icon_name(contact.show) name = contact.name if name == '': name = jid.split('@')[0] iter_ = self.guests_store.append([icon_name, name, jid]) # preselect treeview rows if self.preselected_jids and jid in self.preselected_jids: path = self.guests_store.get_path(iter_) self.guests_treeview.get_selection().select_path(path) # show all self.window.show_all() self.xml.connect_signals(self)
def __init__(self, contact, account, gc_contact=None): EventHelper.__init__(self) # the contact variable is the jid if vcard is true self.xml = get_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 self.avatar = None # Get real jid if gc_contact: # Don't use real jid if room is (semi-)anonymous gc_control = app.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 = configpaths.get('AVATAR') / (puny_jid + '_local') for extension in ('.png', '.jpeg'): local_avatar_path = local_avatar_basepath.with_suffix(extension) if local_avatar_path.is_file(): 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.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) self.register_events([ ('time-result-received', ged.GUI1, self.set_entity_time), ]) self.fill_jabber_page() con = app.connections[self.account] note = con.get_module('Annotations').get_note(self.contact.jid) if note is not None: buffer_ = self.xml.get_object('textview_annotation').get_buffer() buffer_.set_text(note.data) for widget_name in ('URL_label', 'EMAIL_WORK_USERID_label', 'EMAIL_HOME_USERID_label'): widget = self.xml.get_object(widget_name) widget.hide() self.xml.connect_signals(self) self.xml.get_object('close_button').grab_focus() self.window.show_all()
def __init__(self): Gtk.ApplicationWindow.__init__(self) EventHelper.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) self.set_default_size(650, 500) self.set_show_menubar(False) self.set_title(_('Plugins')) self._ui = get_builder('plugins_window.ui') self.add(self._ui.plugins_notebook) # Disable 'Install from ZIP' for Flatpak installs if app.is_flatpak(): self._ui.install_plugin_button.set_tooltip_text( _('Click to view Gajim\'s wiki page on how to install plugins ' 'in Flatpak.')) self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool, GdkPixbuf.Pixbuf) self._ui.installed_plugins_treeview.set_model( self.installed_plugins_model) renderer = Gtk.CellRendererText() col = Gtk.TreeViewColumn(_('Plugin')) # , renderer, text=Column.NAME) cell = Gtk.CellRendererPixbuf() col.pack_start(cell, False) col.add_attribute(cell, 'pixbuf', Column.ICON) col.pack_start(renderer, True) col.add_attribute(renderer, 'text', Column.NAME) col.set_property('expand', True) self._ui.installed_plugins_treeview.append_column(col) renderer = Gtk.CellRendererToggle() renderer.connect('toggled', self._installed_plugin_toggled) col = Gtk.TreeViewColumn(_('Active'), renderer, active=Column.ACTIVE, activatable=Column.ACTIVATABLE) self._ui.installed_plugins_treeview.append_column(col) self.def_icon = load_icon('preferences-desktop', self, pixbuf=True) # connect signal for selection change selection = self._ui.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.connect('destroy', self._on_destroy) self.connect('key-press-event', self._on_key_press) self._ui.connect_signals(self) self._ui.plugins_notebook.set_current_page(0) # Adding GUI extension point for Plugins that want to hook # the Plugin Window app.plugin_manager.gui_extension_point('plugin_window', self) self.register_events([ ('plugin-removed', ged.GUI1, self._on_plugin_removed), ('plugin-added', ged.GUI1, self._on_plugin_added), ]) self.show_all()
def __init__(self, acct, type_, parent_window=None, parent_paned=None): EventHelper.__init__(self) # 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 circular 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 = get_builder('%s.ui' % self.widget_name) self.window = self.xml.get_object(self.widget_name) self.window.set_application(app.app) 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 old_parent = self.notebook.get_parent() old_parent.remove(self.notebook) if app.settings.get('roster_on_the_right'): child1 = self.parent_paned.get_child1() self.parent_paned.remove(child1) self.parent_paned.pack1(self.notebook, resize=False) self.parent_paned.pack2(child1) else: self.parent_paned.pack2(self.notebook) self.window.lookup_action('show-roster').set_enabled(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 self._add_actions() # 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 # Tab customizations pref_pos = app.settings.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 = app.interface.msg_win_mgr.mode if app.settings.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(app.settings.get('tabs_border')) self.show_icon() self.register_events([ ('muc-disco-update', ged.GUI1, self._on_muc_disco_update), ])