show FT window if autopup(away) is set
ask on file exists
This commit is contained in:
parent
3ab41b7e87
commit
a9d00f7412
|
@ -1069,11 +1069,11 @@ class PopupNotificationWindow:
|
||||||
txt = gajim.contacts[account][self.jid][0].name
|
txt = gajim.contacts[account][self.jid][0].name
|
||||||
else:
|
else:
|
||||||
txt = self.jid
|
txt = self.jid
|
||||||
|
|
||||||
event_description_label.set_text(txt)
|
event_description_label.set_text(txt)
|
||||||
|
|
||||||
# set colors [ http://www.w3schools.com/html/html_colornames.asp ]
|
# set colors [ http://www.w3schools.com/html/html_colornames.asp ]
|
||||||
self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
|
self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('black'))
|
||||||
|
|
||||||
if event_type == _('Contact Signed In'):
|
if event_type == _('Contact Signed In'):
|
||||||
limegreen = gtk.gdk.color_parse('limegreen')
|
limegreen = gtk.gdk.color_parse('limegreen')
|
||||||
close_button.modify_bg(gtk.STATE_NORMAL, limegreen)
|
close_button.modify_bg(gtk.STATE_NORMAL, limegreen)
|
||||||
|
@ -1093,6 +1093,7 @@ class PopupNotificationWindow:
|
||||||
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||||
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
|
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||||
txt = _('From %s') % txt
|
txt = _('From %s') % txt
|
||||||
|
|
||||||
elif event_type in [_('File Transfer Completed'), _('File Transfer Stopped')]:
|
elif event_type in [_('File Transfer Completed'), _('File Transfer Stopped')]:
|
||||||
bg_color = gtk.gdk.color_parse('coral')
|
bg_color = gtk.gdk.color_parse('coral')
|
||||||
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||||
|
@ -1160,17 +1161,10 @@ class PopupNotificationWindow:
|
||||||
self.account, contact, self.file_props)
|
self.account, contact, self.file_props)
|
||||||
|
|
||||||
elif self.msg_type == 'file-completed': # it's file request # FIXME: comment
|
elif self.msg_type == 'file-completed': # it's file request # FIXME: comment
|
||||||
sectext = '\t' + _('Filename: %s') % self.file_props['name']
|
self.plugin.windows['file_transfers'].show_completed(self.jid, file_props)
|
||||||
sectext += '\n\t' + _('Size: %s') % \
|
|
||||||
gtkgui_helpers.convert_bytes(self.file_props['size'])
|
|
||||||
sectext += '\n\t' +_('Sender: %s') % self.jid
|
|
||||||
InformationDialog(_('File transfer completed'), sectext).get_response()
|
|
||||||
|
|
||||||
elif self.msg_type == 'file-stopped': # it's file request # FIXME: comment
|
elif self.msg_type == 'file-stopped': # it's file request # FIXME: comment
|
||||||
sectext = '\t' + _('Filename: %s') % self.file_props['name']
|
self.plugin.windows['file_transfers'].show_stopped(self.jid, file_props)
|
||||||
sectext += '\n\t' + _('Sender: %s') % self.jid
|
|
||||||
ErrorDialog(_('File transfer stopped by the contact of the other side'), \
|
|
||||||
sectext).get_response()
|
|
||||||
|
|
||||||
else: # 'chat'
|
else: # 'chat'
|
||||||
self.plugin.roster.new_chat(contact, self.account)
|
self.plugin.roster.new_chat(contact, self.account)
|
||||||
|
@ -1451,6 +1445,29 @@ class FileTransfersWindow:
|
||||||
self.tree.get_selection().set_select_function(self.select_func)
|
self.tree.get_selection().set_select_function(self.select_func)
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
|
|
||||||
|
def show_completed(self, jid, file_props):
|
||||||
|
self.window.present()
|
||||||
|
self.window.window.focus()
|
||||||
|
sectext = '\t' + _('Filename: %s') % \
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(file_props['name'])
|
||||||
|
sectext += '\n\t' + _('Size: %s') % \
|
||||||
|
gtkgui_helpers.convert_bytes(file_props['size'])
|
||||||
|
sectext += '\n\t' +_('Sender: %s') % \
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(jid)
|
||||||
|
InformationDialog(_('File transfer completed'), sectext).get_response()
|
||||||
|
self.tree.get_selection().unselect_all()
|
||||||
|
|
||||||
|
def show_stopped(self, jid, file_props):
|
||||||
|
self.window.present()
|
||||||
|
self.window.window.focus()
|
||||||
|
sectext = '\t' + _('Filename: %s') % \
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(file_props['name'])
|
||||||
|
sectext += '\n\t' + _('Sender: %s') % \
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(jid)
|
||||||
|
ErrorDialog(_('File transfer stopped by the contact of the other side'), \
|
||||||
|
sectext).get_response()
|
||||||
|
self.tree.get_selection().unselect_all()
|
||||||
|
|
||||||
def show_file_send_request(self, account, contact):
|
def show_file_send_request(self, account, contact):
|
||||||
dialog = gtk.FileChooserDialog(title=_('Open File...'),
|
dialog = gtk.FileChooserDialog(title=_('Open File...'),
|
||||||
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
@ -1477,14 +1494,17 @@ class FileTransfersWindow:
|
||||||
def show_file_request(self, account, contact, file_props):
|
def show_file_request(self, account, contact, file_props):
|
||||||
if file_props is None or not file_props.has_key('name'):
|
if file_props is None or not file_props.has_key('name'):
|
||||||
return
|
return
|
||||||
sec_text = '\t' + _('File: %s') % file_props['name']
|
sec_text = '\t' + _('File: %s') % \
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(file_props['name'])
|
||||||
if file_props.has_key('size'):
|
if file_props.has_key('size'):
|
||||||
sec_text += '\n\t' + _('Size: %s') % \
|
sec_text += '\n\t' + _('Size: %s') % \
|
||||||
gtkgui_helpers.convert_bytes(file_props['size'])
|
gtkgui_helpers.convert_bytes(file_props['size'])
|
||||||
if file_props.has_key('mime-type'):
|
if file_props.has_key('mime-type'):
|
||||||
sec_text += '\n\t' + _('Type: %s') % file_props['mime-type']
|
sec_text += '\n\t' + _('Type: %s') % \
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(file_props['mime-type'])
|
||||||
if file_props.has_key('desc'):
|
if file_props.has_key('desc'):
|
||||||
sec_text += '\n\t' + _('Description: %s') % file_props['desc']
|
sec_text += '\n\t' + _('Description: %s') % \
|
||||||
|
gtkgui_helpers.escape_for_pango_markup(file_props['desc'])
|
||||||
prim_text = _('%s wants to send you a file:') % contact.jid
|
prim_text = _('%s wants to send you a file:') % contact.jid
|
||||||
dialog = ConfirmationDialog(prim_text, sec_text)
|
dialog = ConfirmationDialog(prim_text, sec_text)
|
||||||
if dialog.get_response() == gtk.RESPONSE_OK:
|
if dialog.get_response() == gtk.RESPONSE_OK:
|
||||||
|
@ -1497,18 +1517,26 @@ class FileTransfersWindow:
|
||||||
if self.last_save_dir and os.path.exists(self.last_save_dir) \
|
if self.last_save_dir and os.path.exists(self.last_save_dir) \
|
||||||
and os.path.isdir(self.last_save_dir):
|
and os.path.isdir(self.last_save_dir):
|
||||||
dialog.set_current_folder(self.last_save_dir)
|
dialog.set_current_folder(self.last_save_dir)
|
||||||
response = dialog.run()
|
while True:
|
||||||
if response == gtk.RESPONSE_OK:
|
response = dialog.run()
|
||||||
file_path = dialog.get_filename()
|
if response == gtk.RESPONSE_OK:
|
||||||
(file_dir, file_name) = os.path.split(file_path)
|
file_path = dialog.get_filename()
|
||||||
if file_dir:
|
if os.path.exists(file_path):
|
||||||
self.last_save_dir = file_dir
|
primtext = _('This file already exists')
|
||||||
file_props['file-name'] = file_path
|
sectext = _('Would you like to overwrite it?')
|
||||||
self.add_transfer(account, contact, file_props)
|
dialog2 = ConfirmationDialog(primtext, sectext)
|
||||||
gajim.connections[account].send_file_approval(file_props)
|
if dialog2.get_response() != gtk.RESPONSE_OK:
|
||||||
else:
|
continue
|
||||||
gajim.connections[account].send_file_rejection(file_props)
|
(file_dir, file_name) = os.path.split(file_path)
|
||||||
dialog.destroy()
|
if file_dir:
|
||||||
|
self.last_save_dir = file_dir
|
||||||
|
file_props['file-name'] = file_path
|
||||||
|
self.add_transfer(account, contact, file_props)
|
||||||
|
gajim.connections[account].send_file_approval(file_props)
|
||||||
|
else:
|
||||||
|
gajim.connections[account].send_file_rejection(file_props)
|
||||||
|
dialog.destroy()
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
gajim.connections[account].send_file_rejection(file_props)
|
gajim.connections[account].send_file_rejection(file_props)
|
||||||
|
|
||||||
|
@ -1605,8 +1633,8 @@ class FileTransfersWindow:
|
||||||
text_labels += '<b>' + _('Sender: ') + '</b>'
|
text_labels += '<b>' + _('Sender: ') + '</b>'
|
||||||
else:
|
else:
|
||||||
text_labels += '<b>' + _('Recipient: ') + '</b>'
|
text_labels += '<b>' + _('Recipient: ') + '</b>'
|
||||||
text_props = file_props['name'] + '\n'
|
text_props = gtkgui_helpers.escape_for_pango_markup(file_props['name']) + '\n'
|
||||||
text_props += contact.name
|
text_props += gtkgui_helpers.escape_for_pango_markup(contact.name)
|
||||||
self.model.set(iter, 1, text_labels, 2, text_props, 4, \
|
self.model.set(iter, 1, text_labels, 2, text_props, 4, \
|
||||||
file_props['type'] + file_props['sid'])
|
file_props['type'] + file_props['sid'])
|
||||||
self.set_progress(file_props['type'], file_props['sid'], 0, iter)
|
self.set_progress(file_props['type'], file_props['sid'], 0, iter)
|
||||||
|
|
46
src/gajim.py
46
src/gajim.py
|
@ -716,12 +716,17 @@ class Interface:
|
||||||
return
|
return
|
||||||
file_props = array[1]
|
file_props = array[1]
|
||||||
if gajim.config.get('notify_on_new_message'):
|
if gajim.config.get('notify_on_new_message'):
|
||||||
# check OUR status and if we allow notifications for that status
|
# check if we should be notified
|
||||||
if gajim.config.get('autopopupaway') or \
|
instance = dialogs.PopupNotificationWindow(self,
|
||||||
gajim.connections[account].connected in (2, 3): # we're online or chat
|
_('File Transfer Request'), jid, account, 'file', file_props)
|
||||||
instance = dialogs.PopupNotificationWindow(self,
|
self.roster.popup_notification_windows.append(instance)
|
||||||
_('File Transfer Request'), jid, account, 'file', file_props)
|
elif (gajim.connections[account].connected in (2, 3)
|
||||||
self.roster.popup_notification_windows.append(instance)
|
and gajim.config.get('autopopup')) or \
|
||||||
|
gajim.config.get('autopopupaway'):
|
||||||
|
contact = gajim.contacts[account][jid][0]
|
||||||
|
self.windows['file_transfers'].show_file_request(
|
||||||
|
account, contact, file_props)
|
||||||
|
|
||||||
def handle_event_file_progress(self, account, file_props):
|
def handle_event_file_progress(self, account, file_props):
|
||||||
self.windows['file_transfers'].set_progress(file_props['type'],
|
self.windows['file_transfers'].set_progress(file_props['type'],
|
||||||
file_props['sid'], file_props['received-len'])
|
file_props['sid'], file_props['received-len'])
|
||||||
|
@ -733,21 +738,28 @@ class Interface:
|
||||||
file_props['received-len'])
|
file_props['received-len'])
|
||||||
else:
|
else:
|
||||||
ft.set_status(file_props['type'], file_props['sid'], 'stop')
|
ft.set_status(file_props['type'], file_props['sid'], 'stop')
|
||||||
if file_props['stalled'] or file_props['paused']:
|
if file_props.has_key('stalled') and file_props['stalled'] or \
|
||||||
|
file_props.has_key('paused') and file_props['paused']:
|
||||||
return
|
return
|
||||||
|
jid = str(file_props['sender'])
|
||||||
if gajim.config.get('notify_on_file_complete'):
|
if gajim.config.get('notify_on_file_complete'):
|
||||||
if gajim.config.get('autopopupaway') or \
|
if (gajim.connections[account].connected in (2, 3)
|
||||||
gajim.connections[account].connected in (2, 3): # we're online or chat
|
and gajim.config.get('autopopup')) or \
|
||||||
|
gajim.config.get('autopopupaway'):
|
||||||
if file_props['error'] == 0:
|
if file_props['error'] == 0:
|
||||||
msg_type = 'file-completed'
|
ft.show_completed(jid, file_props)
|
||||||
event_type = _('File Transfer Completed')
|
|
||||||
elif file_props['error'] == -1:
|
elif file_props['error'] == -1:
|
||||||
msg_type = 'file-stopped'
|
ft.show_stopped(jid, file_props)
|
||||||
event_type = _('File Transfer Stopped')
|
return
|
||||||
instance = dialogs.PopupNotificationWindow(self, event_type,
|
if file_props['error'] == 0:
|
||||||
str(file_props['sender']), account, msg_type, file_props)
|
msg_type = 'file-completed'
|
||||||
self.roster.popup_notification_windows.append(instance)
|
event_type = _('File Transfer Completed')
|
||||||
|
elif file_props['error'] == -1:
|
||||||
|
msg_type = 'file-stopped'
|
||||||
|
event_type = _('File Transfer Stopped')
|
||||||
|
instance = dialogs.PopupNotificationWindow(self, event_type,
|
||||||
|
jid, account, msg_type, file_props)
|
||||||
|
self.roster.popup_notification_windows.append(instance)
|
||||||
def read_sleepy(self):
|
def read_sleepy(self):
|
||||||
'''Check idle status and change that status if needed'''
|
'''Check idle status and change that status if needed'''
|
||||||
if not self.sleeper.poll():
|
if not self.sleeper.poll():
|
||||||
|
|
Loading…
Reference in New Issue