Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.tree.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, TARGETS,
gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_COPY)
self.tree.enable_model_drag_dest(TARGETS2, gtk.gdk.ACTION_DEFAULT)
self.tree.connect('drag_data_get', self.drag_data_get_data)
self.tree.connect('drag_data_received', self.drag_data_received_data)
self.xml.signal_autoconnect(self)
self.combobox_callback_active = True
self.collapsed_rows = gajim.config.get('collapsed_rows').split('\t')
self.tooltip = tooltips.RosterTooltip()
self.draw_roster()
if gajim.config.get('show_roster_on_startup'):
self.window.show_all()
else:
if not gajim.config.get('trayicon'):
# cannot happen via GUI, but I put this incase user touches
# config. without trayicon, he or she should see the roster!
self.window.show_all()
gajim.config.set('show_roster_on_startup', True)
if len(gajim.connections) == 0: # if we have no account
gajim.interface.instances['account_creation_wizard'] = \
config.AccountCreationWizardWindow()
def show_title(self, urgent=True, control=None):
'''redraw the window's title'''
if not control:
control = self.get_active_control()
if not control:
# No more control in this window
return
unread = 0
for ctrl in self.controls():
if ctrl.type_id == message_control.TYPE_GC and not \
gajim.config.get('notify_on_all_muc_messages') and not \
ctrl.attention_flag:
# count only pm messages
unread += ctrl.get_nb_unread_pm()
continue
unread += ctrl.get_nb_unread()
unread_str = ''
if unread > 1:
unread_str = '[' + unicode(unread) + '] '
elif unread == 1:
unread_str = '* '
else:
urgent = False
if control.type_id == message_control.TYPE_GC:
name = control.room_jid.split('@')[0]
elif ((sys.platform == 'darwin') and\
(gajim.config.get('openwith') == 'open')):
self.applications_combobox.set_active(1)
elif gajim.config.get('openwith') == 'custom':
if sys.platform == 'darwin':
self.applications_combobox.set_active(2)
else:
self.applications_combobox.set_active(4)
self.xml.get_widget('custom_apps_frame').show()
self.xml.get_widget('custom_browser_entry').set_text(
gajim.config.get('custombrowser'))
self.xml.get_widget('custom_mail_client_entry').set_text(
gajim.config.get('custommailapp'))
self.xml.get_widget('custom_file_manager_entry').set_text(
gajim.config.get('custom_file_manager'))
# log status changes of contacts
st = gajim.config.get('log_contact_status_changes')
self.xml.get_widget('log_show_changes_checkbutton').set_active(st)
# log encrypted chat sessions
st = gajim.config.get('log_encrypted_sessions')
self.xml.get_widget('log_encrypted_chats_checkbutton').set_active(st)
# send os info
st = gajim.config.get('send_os_info')
self.xml.get_widget('send_os_info_checkbutton').set_active(st)
# check if gajm is default
st = gajim.config.get('check_if_gajim_is_default')
self.xml.get_widget('check_default_client_checkbutton').set_active(st)
elif ((sys.platform == 'darwin') and\
(gajim.config.get('openwith') == 'open')):
self.applications_combobox.set_active(1)
elif gajim.config.get('openwith') == 'custom':
if sys.platform == 'darwin':
self.applications_combobox.set_active(2)
else:
self.applications_combobox.set_active(4)
self.xml.get_widget('custom_apps_frame').show()
self.xml.get_widget('custom_browser_entry').set_text(
gajim.config.get('custombrowser'))
self.xml.get_widget('custom_mail_client_entry').set_text(
gajim.config.get('custommailapp'))
self.xml.get_widget('custom_file_manager_entry').set_text(
gajim.config.get('custom_file_manager'))
# log status changes of contacts
st = gajim.config.get('log_contact_status_changes')
self.xml.get_widget('log_show_changes_checkbutton').set_active(st)
# log encrypted chat sessions
st = gajim.config.get('log_encrypted_sessions')
self.xml.get_widget('log_encrypted_chats_checkbutton').set_active(st)
# send os info
st = gajim.config.get('send_os_info')
self.xml.get_widget('send_os_info_checkbutton').set_active(st)
# check if gajm is default
st = gajim.config.get('check_if_gajim_is_default')
self.xml.get_widget('check_default_client_checkbutton').set_active(st)
def restore_conversation(self, jid):
# don't restore lines if it's a transport
if gajim.jid_is_transport(jid):
return
# How many lines to restore and when to time them out
restore_how_many = gajim.config.get('restore_lines')
timeout = gajim.config.get('restore_timeout') # in minutes
# number of messages that are in queue and are already logged
pending_how_many = 0 # we want to avoid duplication
if gajim.awaiting_events[self.account].has_key(jid):
events = gajim.awaiting_events[self.account][jid]
for event in events:
if event[0] == 'chat':
pending_how_many += 1
rows = gajim.logger.get_last_conversation_lines(jid, restore_how_many,
pending_how_many, timeout)
for row in rows: # row[0] time, row[1] has kind, row[2] the message
if not row[2]: # message is empty, we don't print it
continue
gajim.automatic_rooms[self.account] = {}
gajim.newly_added[self.account] = []
gajim.to_be_removed[self.account] = []
gajim.nicks[self.account] = config['name']
gajim.block_signed_in_notifications[self.account] = True
gajim.sleeper_state[self.account] = 'off'
gajim.encrypted_chats[self.account] = []
gajim.last_message_time[self.account] = {}
gajim.status_before_autoaway[self.account] = ''
gajim.transport_avatar[self.account] = {}
# refresh accounts window
if gajim.interface.instances.has_key('accounts'):
gajim.interface.instances['accounts'].init_accounts()
# refresh roster
if len(gajim.connections) >= 2: # Do not merge accounts if only one exists
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else:
gajim.interface.roster.regroup = False
gajim.interface.roster.draw_roster()
gajim.interface.roster.actions_menu_needs_rebuild = True
gajim.interface.save_config()
if file_props['error'] == 0:
ft.set_progress(file_props['type'], file_props['sid'],
file_props['received-len'])
else:
ft.set_status(file_props['type'], file_props['sid'], 'stop')
if file_props.has_key('stalled') and file_props['stalled'] or \
file_props.has_key('paused') and file_props['paused']:
return
if file_props['type'] == 'r': # we receive a file
jid = unicode(file_props['sender'])
else: # we send a file
jid = unicode(file_props['receiver'])
if helpers.allow_popup_window(account):
if file_props['error'] == 0:
if gajim.config.get('notify_on_file_complete'):
ft.show_completed(jid, file_props)
elif file_props['error'] == -1:
ft.show_stopped(jid, file_props)
return
msg_type = ''
event_type = ''
if file_props['error'] == 0 and gajim.config.get('notify_on_file_complete'):
msg_type = 'file-completed'
event_type = _('File Transfer Completed')
elif file_props['error'] == -1:
msg_type = 'file-stopped'
event_type = _('File Transfer Stopped')
if event_type == '':
# FIXME: ugly workaround (this can happen Gajim sent, Gaim recvs)
def on_reset_colors_button_clicked(self, widget):
for i in ('inmsgcolor', 'outmsgcolor', 'statusmsgcolor', 'urlmsgcolor'):
gajim.config.set(i, gajim.interface.default_colors[i])
self.xml.get_widget('incoming_msg_colorbutton').set_color(\
gtk.gdk.color_parse(gajim.config.get('inmsgcolor')))
self.xml.get_widget('outgoing_msg_colorbutton').set_color(\
gtk.gdk.color_parse(gajim.config.get('outmsgcolor')))
self.xml.get_widget('status_msg_colorbutton').set_color(\
gtk.gdk.color_parse(gajim.config.get('statusmsgcolor')))
self.xml.get_widget('url_msg_colorbutton').set_color(\
gtk.gdk.color_parse(gajim.config.get('urlmsgcolor')))
self.update_text_tags()
gajim.interface.save_config()
event.keyval = event_keyval
event.state = event_keymod
event.time = 0 # assign current time
if event.keyval == gtk.keysyms.Up:
if event.state & gtk.gdk.CONTROL_MASK: # Ctrl+UP
self.sent_messages_scroll('up', widget.get_buffer())
elif event.keyval == gtk.keysyms.Down:
if event.state & gtk.gdk.CONTROL_MASK: # Ctrl+Down
self.sent_messages_scroll('down', widget.get_buffer())
elif event.keyval == gtk.keysyms.Return or \
event.keyval == gtk.keysyms.KP_Enter: # ENTER
# NOTE: SHIFT + ENTER is not needed to be emulated as it is not
# binding at all (textview's default action is newline)
if gajim.config.get('send_on_ctrl_enter'):
# here, we emulate GTK default action on ENTER (add new line)
# normally I would add in keypress but it gets way to complex
# to get instant result on changing this advanced setting
if event.state == 0: # no ctrl, no shift just ENTER add newline
end_iter = message_buffer.get_end_iter()
message_buffer.insert_at_cursor('\n')
send_message = False
elif event.state & gtk.gdk.CONTROL_MASK: # CTRL + ENTER
send_message = True
else: # send on Enter, do newline on Ctrl Enter
if event.state & gtk.gdk.CONTROL_MASK: # Ctrl + ENTER
end_iter = message_buffer.get_end_iter()
message_buffer.insert_at_cursor('\n')
send_message = False
else: # ENTER
send_message = True