Move ProfileWindow into gtk module
This commit is contained in:
parent
8c299c0b77
commit
78e4e20d49
|
@ -56,3 +56,4 @@ from gajim.gtk.single_message import SingleMessageWindow
|
||||||
from gajim.gtk.server_info import ServerInfoDialog
|
from gajim.gtk.server_info import ServerInfoDialog
|
||||||
from gajim.gtk.pep_config import ManagePEPServicesWindow
|
from gajim.gtk.pep_config import ManagePEPServicesWindow
|
||||||
from gajim.gtk.bookmarks import ManageBookmarksWindow
|
from gajim.gtk.bookmarks import ManageBookmarksWindow
|
||||||
|
from gajim.gtk.profile import ProfileWindow
|
||||||
|
|
|
@ -1,24 +1,20 @@
|
||||||
# -*- coding:utf-8 -*-
|
# Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
||||||
## src/profile_window.py
|
# Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
||||||
##
|
# Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
||||||
## Copyright (C) 2003-2014 Yann Leboulanger <asterix AT lagaule.org>
|
#
|
||||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem AT gmail.com>
|
# This file is part of Gajim.
|
||||||
## Copyright (C) 2006-2008 Jean-Marie Traissard <jim AT lapin.org>
|
#
|
||||||
##
|
# Gajim is free software; you can redistribute it and/or modify
|
||||||
## This file is part of Gajim.
|
# it under the terms of the GNU General Public License as published
|
||||||
##
|
# by the Free Software Foundation; version 3 only.
|
||||||
## Gajim is free software; you can redistribute it and/or modify
|
#
|
||||||
## it under the terms of the GNU General Public License as published
|
# Gajim is distributed in the hope that it will be useful,
|
||||||
## by the Free Software Foundation; version 3 only.
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
##
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
## Gajim is distributed in the hope that it will be useful,
|
# GNU General Public License for more details.
|
||||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
#
|
||||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# You should have received a copy of the GNU General Public License
|
||||||
## GNU General Public License for more details.
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
|
||||||
## You should have received a copy of the GNU General Public License
|
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
##
|
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import time
|
import time
|
||||||
|
@ -32,6 +28,7 @@ from gi.repository import GLib
|
||||||
from gajim import gtkgui_helpers
|
from gajim import gtkgui_helpers
|
||||||
from gajim.gtk import ErrorDialog
|
from gajim.gtk import ErrorDialog
|
||||||
from gajim.gtk import InformationDialog
|
from gajim.gtk import InformationDialog
|
||||||
|
from gajim.gtk.util import get_builder
|
||||||
from gajim.filechoosers import AvatarChooserDialog
|
from gajim.filechoosers import AvatarChooserDialog
|
||||||
from gajim.common.const import AvatarSize
|
from gajim.common.const import AvatarSize
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
|
@ -51,7 +48,7 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
self.connect('destroy', self.on_profile_window_destroy)
|
self.connect('destroy', self.on_profile_window_destroy)
|
||||||
self.connect('key-press-event', self.on_profile_window_key_press_event)
|
self.connect('key-press-event', self.on_profile_window_key_press_event)
|
||||||
|
|
||||||
self.xml = gtkgui_helpers.get_gtk_builder('profile_window.ui')
|
self.xml = get_builder('profile_window.ui')
|
||||||
self.add(self.xml.get_object('profile_box'))
|
self.add(self.xml.get_object('profile_box'))
|
||||||
self.progressbar = self.xml.get_object('progressbar')
|
self.progressbar = self.xml.get_object('progressbar')
|
||||||
self.statusbar = self.xml.get_object('statusbar')
|
self.statusbar = self.xml.get_object('statusbar')
|
||||||
|
@ -89,7 +86,7 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
def update_progressbar(self):
|
def update_progressbar(self):
|
||||||
self.progressbar.pulse()
|
self.progressbar.pulse()
|
||||||
return True # loop forever
|
return True
|
||||||
|
|
||||||
def remove_statusbar(self, message_id):
|
def remove_statusbar(self, message_id):
|
||||||
self.statusbar.remove(self.context_id, message_id)
|
self.statusbar.remove(self.context_id, message_id)
|
||||||
|
@ -100,10 +97,10 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
GLib.source_remove(self.update_progressbar_timeout_id)
|
GLib.source_remove(self.update_progressbar_timeout_id)
|
||||||
if self.remove_statusbar_timeout_id is not None:
|
if self.remove_statusbar_timeout_id is not None:
|
||||||
GLib.source_remove(self.remove_statusbar_timeout_id)
|
GLib.source_remove(self.remove_statusbar_timeout_id)
|
||||||
app.ged.remove_event_handler('vcard-published', ged.GUI1,
|
app.ged.remove_event_handler(
|
||||||
self._nec_vcard_published)
|
'vcard-published', ged.GUI1, self._nec_vcard_published)
|
||||||
app.ged.remove_event_handler('vcard-not-published', ged.GUI1,
|
app.ged.remove_event_handler(
|
||||||
self._nec_vcard_not_published)
|
'vcard-not-published', ged.GUI1, self._nec_vcard_not_published)
|
||||||
|
|
||||||
if self.dialog: # Image chooser dialog
|
if self.dialog: # Image chooser dialog
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
|
@ -161,11 +158,12 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
nick = app.config.get_per('accounts', self.account, 'name')
|
nick = app.config.get_per('accounts', self.account, 'name')
|
||||||
sha = app.contacts.get_avatar_sha(self.account, self.jid)
|
sha = app.contacts.get_avatar_sha(self.account, self.jid)
|
||||||
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
|
menuitem = Gtk.MenuItem.new_with_mnemonic(_('Save _As'))
|
||||||
menuitem.connect('activate',
|
menuitem.connect(
|
||||||
|
'activate',
|
||||||
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
gtkgui_helpers.on_avatar_save_as_menuitem_activate,
|
||||||
sha, nick)
|
sha, nick)
|
||||||
menu.append(menuitem)
|
menu.append(menuitem)
|
||||||
menu.connect('selection-done', lambda w:w.destroy())
|
menu.connect('selection-done', lambda w: w.destroy())
|
||||||
# show the menu
|
# show the menu
|
||||||
menu.show_all()
|
menu.show_all()
|
||||||
menu.attach_to_widget(widget, None)
|
menu.attach_to_widget(widget, None)
|
||||||
|
@ -182,8 +180,10 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if not widget.is_focus():
|
if not widget.is_focus():
|
||||||
pritext = _('Wrong date format')
|
pritext = _('Wrong date format')
|
||||||
ErrorDialog(pritext, _('Format of the date must be '
|
ErrorDialog(
|
||||||
'YYYY-MM-DD'), transient_for=self)
|
pritext,
|
||||||
|
_('Format of the date must be YYYY-MM-DD'),
|
||||||
|
transient_for=self)
|
||||||
GLib.idle_add(lambda: widget.grab_focus())
|
GLib.idle_add(lambda: widget.grab_focus())
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
button = self.xml.get_object('PHOTO_button')
|
button = self.xml.get_object('PHOTO_button')
|
||||||
image = self.xml.get_object('PHOTO_image')
|
image = self.xml.get_object('PHOTO_image')
|
||||||
text_button = self.xml.get_object('NOPHOTO_button')
|
text_button = self.xml.get_object('NOPHOTO_button')
|
||||||
if not 'PHOTO' in vcard_:
|
if 'PHOTO' not in vcard_:
|
||||||
# set default image
|
# set default image
|
||||||
image.set_from_pixbuf(None)
|
image.set_from_pixbuf(None)
|
||||||
button.hide()
|
button.hide()
|
||||||
|
@ -248,10 +248,10 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
if self.update_progressbar_timeout_id is not None:
|
if self.update_progressbar_timeout_id is not None:
|
||||||
if self.message_id:
|
if self.message_id:
|
||||||
self.statusbar.remove(self.context_id, self.message_id)
|
self.statusbar.remove(self.context_id, self.message_id)
|
||||||
self.message_id = self.statusbar.push(self.context_id,
|
self.message_id = self.statusbar.push(
|
||||||
_('Information received'))
|
self.context_id, _('Information received'))
|
||||||
self.remove_statusbar_timeout_id = GLib.timeout_add_seconds(3,
|
self.remove_statusbar_timeout_id = GLib.timeout_add_seconds(
|
||||||
self.remove_statusbar, self.message_id)
|
3, self.remove_statusbar, self.message_id)
|
||||||
GLib.source_remove(self.update_progressbar_timeout_id)
|
GLib.source_remove(self.update_progressbar_timeout_id)
|
||||||
self.progressbar.hide()
|
self.progressbar.hide()
|
||||||
self.progressbar.set_fraction(0)
|
self.progressbar.set_fraction(0)
|
||||||
|
@ -269,7 +269,7 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
if len(entries) == 3: # We need to use lists
|
if len(entries) == 3: # We need to use lists
|
||||||
if entries[0] not in loc:
|
if entries[0] not in loc:
|
||||||
loc[entries[0]] = []
|
loc[entries[0]] = []
|
||||||
found = False
|
|
||||||
for e in loc[entries[0]]:
|
for e in loc[entries[0]]:
|
||||||
if entries[1] in e:
|
if entries[1] in e:
|
||||||
e[entries[2]] = txt
|
e[entries[2]] = txt
|
||||||
|
@ -289,7 +289,8 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
"""
|
"""
|
||||||
Make the vCard dictionary
|
Make the vCard dictionary
|
||||||
"""
|
"""
|
||||||
entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'JABBERID', 'URL',
|
entries = [
|
||||||
|
'FN', 'NICKNAME', 'BDAY', 'EMAIL_HOME_USERID', 'JABBERID', 'URL',
|
||||||
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
|
'TEL_HOME_NUMBER', 'N_FAMILY', 'N_GIVEN', 'N_MIDDLE', 'N_PREFIX',
|
||||||
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
|
'N_SUFFIX', 'ADR_HOME_STREET', 'ADR_HOME_EXTADR', 'ADR_HOME_LOCALITY',
|
||||||
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
|
'ADR_HOME_REGION', 'ADR_HOME_PCODE', 'ADR_HOME_CTRY', 'ORG_ORGNAME',
|
||||||
|
@ -322,9 +323,11 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
# Operation in progress
|
# Operation in progress
|
||||||
return
|
return
|
||||||
if app.connections[self.account].connected < 2:
|
if app.connections[self.account].connected < 2:
|
||||||
ErrorDialog(_('You are not connected to the server'),
|
ErrorDialog(
|
||||||
|
_('You are not connected to the server'),
|
||||||
_('Without a connection, you can not publish your contact '
|
_('Without a connection, you can not publish your contact '
|
||||||
'information.'), transient_for=self)
|
'information.'),
|
||||||
|
transient_for=self)
|
||||||
return
|
return
|
||||||
vcard_, sha = self.make_vcard()
|
vcard_, sha = self.make_vcard()
|
||||||
nick = ''
|
nick = ''
|
||||||
|
@ -337,11 +340,11 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
app.nicks[self.account] = nick
|
app.nicks[self.account] = nick
|
||||||
app.connections[self.account].get_module('VCardTemp').send_vcard(
|
app.connections[self.account].get_module('VCardTemp').send_vcard(
|
||||||
vcard_, sha)
|
vcard_, sha)
|
||||||
self.message_id = self.statusbar.push(self.context_id,
|
self.message_id = self.statusbar.push(
|
||||||
_('Sending profile…'))
|
self.context_id, _('Sending profile…'))
|
||||||
self.progressbar.show()
|
self.progressbar.show()
|
||||||
self.update_progressbar_timeout_id = GLib.timeout_add(100,
|
self.update_progressbar_timeout_id = GLib.timeout_add(
|
||||||
self.update_progressbar)
|
100, self.update_progressbar)
|
||||||
|
|
||||||
def _nec_vcard_published(self, obj):
|
def _nec_vcard_published(self, obj):
|
||||||
if obj.conn.name != self.account:
|
if obj.conn.name != self.account:
|
||||||
|
@ -356,15 +359,16 @@ class ProfileWindow(Gtk.ApplicationWindow):
|
||||||
return
|
return
|
||||||
if self.message_id:
|
if self.message_id:
|
||||||
self.statusbar.remove(self.context_id, self.message_id)
|
self.statusbar.remove(self.context_id, self.message_id)
|
||||||
self.message_id = self.statusbar.push(self.context_id,
|
self.message_id = self.statusbar.push(
|
||||||
_('Information NOT published'))
|
self.context_id, _('Information NOT published'))
|
||||||
self.remove_statusbar_timeout_id = GLib.timeout_add_seconds(3,
|
self.remove_statusbar_timeout_id = GLib.timeout_add_seconds(
|
||||||
self.remove_statusbar, self.message_id)
|
3, self.remove_statusbar, self.message_id)
|
||||||
if self.update_progressbar_timeout_id is not None:
|
if self.update_progressbar_timeout_id is not None:
|
||||||
GLib.source_remove(self.update_progressbar_timeout_id)
|
GLib.source_remove(self.update_progressbar_timeout_id)
|
||||||
self.progressbar.set_fraction(0)
|
self.progressbar.set_fraction(0)
|
||||||
self.update_progressbar_timeout_id = None
|
self.update_progressbar_timeout_id = None
|
||||||
InformationDialog(_('vCard publication failed'),
|
InformationDialog(
|
||||||
|
_('vCard publication failed'),
|
||||||
_('There was an error while publishing your personal information, '
|
_('There was an error while publishing your personal information, '
|
||||||
'try again later.'), transient_for=self)
|
'try again later.'), transient_for=self)
|
||||||
|
|
|
@ -106,7 +106,6 @@ from gajim.common.const import AvatarSize, SSLError, PEPEventType
|
||||||
from gajim.common.const import ACTIVITIES, MOODS
|
from gajim.common.const import ACTIVITIES, MOODS
|
||||||
|
|
||||||
from gajim import roster_window
|
from gajim import roster_window
|
||||||
from gajim import profile_window
|
|
||||||
from gajim import config
|
from gajim import config
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from gajim.common import ged
|
from gajim.common import ged
|
||||||
|
@ -123,6 +122,7 @@ from gajim.gtk import PlainConnectionDialog
|
||||||
from gajim.gtk import SSLErrorDialog
|
from gajim.gtk import SSLErrorDialog
|
||||||
from gajim.gtk import ConfirmationDialogDoubleCheck
|
from gajim.gtk import ConfirmationDialogDoubleCheck
|
||||||
from gajim.gtk import ChangeNickDialog
|
from gajim.gtk import ChangeNickDialog
|
||||||
|
from gajim.gtk import ProfileWindow
|
||||||
|
|
||||||
from gajim.common import configpaths
|
from gajim.common import configpaths
|
||||||
|
|
||||||
|
@ -284,9 +284,9 @@ class Interface:
|
||||||
self.show_vcard_when_connect.remove(account)
|
self.show_vcard_when_connect.remove(account)
|
||||||
|
|
||||||
def edit_own_details(self, account):
|
def edit_own_details(self, account):
|
||||||
window = app.get_app_window(profile_window.ProfileWindow)
|
window = app.get_app_window(ProfileWindow)
|
||||||
if window is None:
|
if window is None:
|
||||||
profile_window.ProfileWindow(account)
|
ProfileWindow(account)
|
||||||
else:
|
else:
|
||||||
window.present()
|
window.present()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue