2006-03-15 12:59:01 +00:00
# -*- coding: utf-8 -*-
2005-04-18 14:05:30 +00:00
## dialogs.py
2004-05-15 16:50:38 +00:00
##
2006-02-04 01:08:37 +00:00
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
## Copyright (C) 2003-2004 Vincent Hanquez <tab@snarc.org>
2006-02-06 21:35:54 +00:00
## Copyright (C) 2005-2006 Nikos Kouremenos <nkour@jabber.org>
2006-02-04 01:08:37 +00:00
## Copyright (C) 2005 Dimitur Kirov <dkirov@gmail.com>
## Copyright (C) 2005-2006 Travis Shirk <travis@pobox.com>
## Copyright (C) 2005 Norman Rasmussen <norman@rasmussen.co.za>
2004-05-15 16:50:38 +00:00
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 2 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
import gtk
2005-03-01 13:46:22 +00:00
import gtk . glade
import gobject
2005-05-17 17:37:50 +00:00
import os
2006-03-24 18:48:26 +00:00
import sys
2005-05-20 15:58:23 +00:00
2005-07-21 21:42:53 +00:00
import gtkgui_helpers
2005-11-13 20:25:04 +00:00
import vcard
2005-12-12 09:12:29 +00:00
import conversation_textview
2005-07-21 21:39:47 +00:00
2005-11-30 22:22:22 +00:00
try :
import gtkspell
HAS_GTK_SPELL = True
except :
HAS_GTK_SPELL = False
2006-03-24 18:49:47 +00:00
# those imports are not used in this file, but in files that 'import dialogs'
2006-03-24 18:48:26 +00:00
# so they can do dialog.GajimThemesWindow() for example
2005-08-14 23:52:12 +00:00
from filetransfers_window import FileTransfersWindow
2005-06-09 22:29:06 +00:00
from gajim_themes_window import GajimThemesWindow
2005-06-10 22:45:50 +00:00
from advanced import AdvancedConfigurationWindow
2006-03-24 18:48:26 +00:00
2005-04-14 07:05:10 +00:00
from common import gajim
2005-06-06 11:53:07 +00:00
from common import helpers
2005-08-14 23:52:12 +00:00
from common import i18n
2005-05-20 15:58:23 +00:00
2004-05-16 23:47:14 +00:00
_ = i18n . _
APP = i18n . APP
gtk . glade . bindtextdomain ( APP , i18n . DIR )
gtk . glade . textdomain ( APP )
2004-05-15 16:50:38 +00:00
2005-04-21 23:20:18 +00:00
GTKGUI_GLADE = ' gtkgui.glade '
2004-05-15 16:50:38 +00:00
2005-06-10 21:14:16 +00:00
class EditGroupsDialog :
2005-04-18 12:17:43 +00:00
''' Class for the edit group dialog window '''
2005-10-20 11:17:17 +00:00
def __init__ ( self , user , account ) :
2005-03-17 17:41:09 +00:00
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' edit_groups_dialog ' , APP )
self . dialog = self . xml . get_widget ( ' edit_groups_dialog ' )
self . account = account
self . user = user
2005-04-17 21:31:18 +00:00
self . changes_made = False
2005-03-17 17:41:09 +00:00
self . list = self . xml . get_widget ( ' groups_treeview ' )
2005-05-19 17:47:40 +00:00
self . xml . get_widget ( ' nickname_label ' ) . set_markup (
2006-01-10 18:30:57 +00:00
_ ( " Contact ' s name: <i> %s </i> " ) % user . get_shown_name ( ) )
2005-05-19 17:47:40 +00:00
self . xml . get_widget ( ' jid_label ' ) . set_markup (
2005-03-18 00:47:50 +00:00
_ ( ' JID: <i> %s </i> ' ) % user . jid )
2005-07-22 22:32:45 +00:00
2005-03-17 17:41:09 +00:00
self . xml . signal_autoconnect ( self )
self . init_list ( )
def run ( self ) :
2005-07-22 22:32:45 +00:00
self . dialog . show_all ( )
2005-04-17 21:31:18 +00:00
if self . changes_made :
2005-07-18 14:52:28 +00:00
gajim . connections [ self . account ] . update_contact ( self . user . jid ,
2005-04-17 21:31:18 +00:00
self . user . name , self . user . groups )
2005-03-17 17:41:09 +00:00
2005-07-22 22:32:45 +00:00
def on_edit_groups_dialog_response ( self , widget , response_id ) :
if response_id == gtk . RESPONSE_CLOSE :
self . dialog . destroy ( )
2005-07-18 14:52:28 +00:00
def update_contact ( self ) :
2006-03-29 20:26:20 +00:00
tag = gajim . contacts . get_metacontacts_tag ( self . account , self . user . jid )
2006-03-29 21:00:33 +00:00
if not tag :
gajim . interface . roster . remove_contact ( self . user , self . account )
gajim . interface . roster . add_contact_to_roster ( self . user . jid ,
self . account )
gajim . connections [ self . account ] . update_contact ( self . user . jid ,
self . user . name , self . user . groups )
return
2006-03-29 20:26:20 +00:00
all_jid = gajim . contacts . get_metacontacts_jids ( tag )
for _account in all_jid :
for _jid in all_jid [ _account ] :
c = gajim . contacts . get_first_contact_from_jid ( _account , _jid )
if not c :
continue
gajim . interface . roster . remove_contact ( c , _account )
gajim . interface . roster . add_contact_to_roster ( _jid , _account )
gajim . connections [ _account ] . update_contact ( _jid , c . name , c . groups )
def remove_group ( self , group ) :
''' add group group to self.user and all his brothers '''
tag = gajim . contacts . get_metacontacts_tag ( self . account , self . user . jid )
2006-03-29 21:00:33 +00:00
if not tag :
if group in self . user . groups :
self . user . groups . remove ( group )
return
2006-03-29 20:26:20 +00:00
all_jid = gajim . contacts . get_metacontacts_jids ( tag )
for _account in all_jid :
for _jid in all_jid [ _account ] :
contacts = gajim . contacts . get_contact ( _account , _jid )
for contact in contacts :
if group in contact . groups :
contact . groups . remove ( group )
def add_group ( self , group ) :
''' add group group to self.user and all his brothers '''
tag = gajim . contacts . get_metacontacts_tag ( self . account , self . user . jid )
2006-03-29 21:00:33 +00:00
if not tag :
if group not in self . user . groups :
self . user . groups . append ( group )
return
2006-03-29 20:26:20 +00:00
all_jid = gajim . contacts . get_metacontacts_jids ( tag )
for _account in all_jid :
for _jid in all_jid [ _account ] :
contacts = gajim . contacts . get_contact ( _account , _jid )
for contact in contacts :
if not group in contact . groups :
contact . groups . append ( group )
2005-03-17 17:41:09 +00:00
def on_add_button_clicked ( self , widget ) :
2005-08-26 00:52:44 +00:00
group = self . xml . get_widget ( ' group_entry ' ) . get_text ( ) . decode ( ' utf-8 ' )
2005-03-17 17:41:09 +00:00
if not group :
return
# check if it already exists
model = self . list . get_model ( )
iter = model . get_iter_root ( )
while iter :
2005-08-26 00:52:44 +00:00
if model . get_value ( iter , 0 ) . decode ( ' utf-8 ' ) == group :
2005-03-17 17:41:09 +00:00
return
iter = model . iter_next ( iter )
2005-05-23 17:21:05 +00:00
self . changes_made = True
2005-03-17 17:41:09 +00:00
model . append ( ( group , True ) )
2006-03-29 20:26:20 +00:00
self . add_group ( group )
2005-07-18 14:52:28 +00:00
self . update_contact ( )
2005-03-17 17:41:09 +00:00
def group_toggled_cb ( self , cell , path ) :
2005-04-17 21:31:18 +00:00
self . changes_made = True
2005-03-17 17:41:09 +00:00
model = self . list . get_model ( )
model [ path ] [ 1 ] = not model [ path ] [ 1 ]
2006-03-29 20:26:20 +00:00
group = model [ path ] [ 0 ] . decode ( ' utf-8 ' )
if model [ path ] [ 1 ] :
self . add_group ( group )
else :
self . remove_group ( group )
2005-07-18 14:52:28 +00:00
self . update_contact ( )
2005-03-17 17:41:09 +00:00
def init_list ( self ) :
2005-06-18 13:48:43 +00:00
store = gtk . ListStore ( str , bool )
2005-03-17 17:41:09 +00:00
self . list . set_model ( store )
2005-07-18 21:08:31 +00:00
for g in gajim . groups [ self . account ] . keys ( ) :
2006-03-30 21:35:43 +00:00
if g in helpers . special_groups :
2005-06-01 20:47:01 +00:00
continue
2005-03-17 17:41:09 +00:00
iter = store . append ( )
store . set ( iter , 0 , g )
if g in self . user . groups :
store . set ( iter , 1 , True )
else :
store . set ( iter , 1 , False )
column = gtk . TreeViewColumn ( _ ( ' Group ' ) )
2005-08-29 00:01:43 +00:00
column . set_expand ( True )
2005-03-17 17:41:09 +00:00
self . list . append_column ( column )
renderer = gtk . CellRendererText ( )
column . pack_start ( renderer )
2005-04-21 23:20:18 +00:00
column . set_attributes ( renderer , text = 0 )
2005-03-17 17:41:09 +00:00
column = gtk . TreeViewColumn ( _ ( ' In the group ' ) )
2005-08-29 00:01:43 +00:00
column . set_expand ( False )
2005-03-17 17:41:09 +00:00
self . list . append_column ( column )
renderer = gtk . CellRendererToggle ( )
column . pack_start ( renderer )
renderer . set_property ( ' activatable ' , True )
renderer . connect ( ' toggled ' , self . group_toggled_cb )
2005-04-21 23:20:18 +00:00
column . set_attributes ( renderer , active = 1 )
2005-03-17 17:41:09 +00:00
2005-06-10 21:14:16 +00:00
class PassphraseDialog :
2005-04-18 12:17:43 +00:00
''' Class for Passphrase dialog '''
2004-10-07 14:43:59 +00:00
def run ( self ) :
2005-04-18 12:17:43 +00:00
''' Wait for OK button to be pressed and return passphrase/password '''
2005-03-02 10:46:12 +00:00
rep = self . window . run ( )
2004-10-07 14:43:59 +00:00
if rep == gtk . RESPONSE_OK :
2005-08-26 00:52:44 +00:00
passphrase = self . passphrase_entry . get_text ( ) . decode ( ' utf-8 ' )
2004-10-07 14:43:59 +00:00
else :
2005-03-02 10:46:12 +00:00
passphrase = - 1
save_passphrase_checkbutton = self . xml . \
get_widget ( ' save_passphrase_checkbutton ' )
self . window . destroy ( )
2005-03-15 10:20:10 +00:00
return passphrase , save_passphrase_checkbutton . get_active ( )
2004-12-02 00:00:57 +00:00
2005-06-03 10:28:53 +00:00
def __init__ ( self , titletext , labeltext , checkbuttontext ) :
2005-03-02 10:46:12 +00:00
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' passphrase_dialog ' , APP )
self . window = self . xml . get_widget ( ' passphrase_dialog ' )
self . passphrase_entry = self . xml . get_widget ( ' passphrase_entry ' )
self . passphrase = - 1
2005-06-03 10:28:53 +00:00
self . window . set_title ( titletext )
2005-03-02 12:38:33 +00:00
self . xml . get_widget ( ' message_label ' ) . set_text ( labeltext )
2005-07-22 22:49:03 +00:00
self . xml . get_widget ( ' save_passphrase_checkbutton ' ) . set_label (
checkbuttontext )
2005-03-02 10:46:12 +00:00
self . xml . signal_autoconnect ( self )
2005-04-04 15:51:29 +00:00
self . window . show_all ( )
2004-05-15 16:50:38 +00:00
2005-06-08 13:45:30 +00:00
class ChooseGPGKeyDialog :
2005-04-18 12:17:43 +00:00
''' Class for GPG key dialog '''
2005-06-08 13:45:30 +00:00
def __init__ ( self , title_text , prompt_text , secret_keys , selected = None ) :
2004-10-10 18:44:38 +00:00
#list : {keyID: userName, ...}
2005-03-02 11:46:51 +00:00
xml = gtk . glade . XML ( GTKGUI_GLADE , ' choose_gpg_key_dialog ' , APP )
self . window = xml . get_widget ( ' choose_gpg_key_dialog ' )
2005-06-08 13:45:30 +00:00
self . window . set_title ( title_text )
2005-03-02 11:46:51 +00:00
self . keys_treeview = xml . get_widget ( ' keys_treeview ' )
2005-06-08 13:45:30 +00:00
prompt_label = xml . get_widget ( ' prompt_label ' )
prompt_label . set_text ( prompt_text )
2005-06-18 13:48:43 +00:00
model = gtk . ListStore ( str , str )
2005-10-22 08:52:13 +00:00
model . set_sort_column_id ( 1 , gtk . SORT_ASCENDING )
2005-03-02 11:46:51 +00:00
self . keys_treeview . set_model ( model )
2004-10-10 18:44:38 +00:00
#columns
renderer = gtk . CellRendererText ( )
2005-05-19 17:47:40 +00:00
self . keys_treeview . insert_column_with_attributes ( - 1 , _ ( ' KeyID ' ) ,
2005-04-21 23:20:18 +00:00
renderer , text = 0 )
2004-10-10 18:44:38 +00:00
renderer = gtk . CellRendererText ( )
2005-06-24 14:28:00 +00:00
self . keys_treeview . insert_column_with_attributes ( - 1 , _ ( ' Contact name ' ) ,
2005-04-21 23:20:18 +00:00
renderer , text = 1 )
2005-05-29 21:34:01 +00:00
self . fill_tree ( secret_keys , selected )
2005-04-04 15:51:29 +00:00
self . window . show_all ( )
2005-08-02 16:27:25 +00:00
def run ( self ) :
rep = self . window . run ( )
if rep == gtk . RESPONSE_OK :
2005-07-22 22:49:03 +00:00
selection = self . keys_treeview . get_selection ( )
( model , iter ) = selection . get_selected ( )
2005-09-25 19:00:14 +00:00
keyID = [ model [ iter ] [ 0 ] . decode ( ' utf-8 ' ) ,
model [ iter ] [ 1 ] . decode ( ' utf-8 ' ) ]
2005-08-02 16:27:25 +00:00
else :
keyID = None
2005-07-22 22:49:03 +00:00
self . window . destroy ( )
2005-08-02 16:27:25 +00:00
return keyID
2005-07-22 22:49:03 +00:00
def fill_tree ( self , list , selected ) :
model = self . keys_treeview . get_model ( )
for keyID in list . keys ( ) :
iter = model . append ( ( keyID , list [ keyID ] ) )
if keyID == selected :
path = model . get_path ( iter )
self . keys_treeview . set_cursor ( path )
2005-06-10 21:14:16 +00:00
class ChangeStatusMessageDialog :
2005-10-20 11:17:17 +00:00
def __init__ ( self , show = None ) :
2005-06-30 19:23:41 +00:00
self . show = show
2006-03-07 14:02:45 +00:00
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' change_status_message_dialog ' ,
APP )
2005-04-04 16:46:35 +00:00
self . window = self . xml . get_widget ( ' change_status_message_dialog ' )
2005-10-09 14:44:52 +00:00
if show :
uf_show = helpers . get_uf_show ( show )
2005-10-09 18:42:24 +00:00
title_text = _ ( ' %s Status Message ' ) % uf_show
2005-10-09 14:44:52 +00:00
else :
2005-10-09 18:42:24 +00:00
title_text = _ ( ' Status Message ' )
2005-10-09 18:42:41 +00:00
self . window . set_title ( title_text )
2005-05-12 09:14:31 +00:00
2005-04-04 16:46:35 +00:00
message_textview = self . xml . get_widget ( ' message_textview ' )
self . message_buffer = message_textview . get_buffer ( )
2006-01-26 17:40:11 +00:00
self . message_buffer . connect ( ' changed ' ,
self . toggle_sensitiviy_of_save_as_preset )
2005-10-09 14:44:52 +00:00
msg = None
if show :
msg = gajim . config . get ( ' last_status_msg_ ' + show )
2005-06-30 19:23:41 +00:00
if not msg :
msg = ' '
2005-07-02 12:43:36 +00:00
msg = helpers . from_one_line ( msg )
2005-06-30 19:23:41 +00:00
self . message_buffer . set_text ( msg )
2006-03-07 14:02:45 +00:00
# have an empty string selectable, so user can clear msg
self . preset_messages_dict = { ' ' : ' ' }
for msg_name in gajim . config . get_per ( ' statusmsg ' ) :
msg_text = gajim . config . get_per ( ' statusmsg ' , msg_name , ' message ' )
msg_text = helpers . from_one_line ( msg_text )
self . preset_messages_dict [ msg_name ] = msg_text
sorted_keys_list = helpers . get_sorted_keys ( self . preset_messages_dict )
self . message_liststore = gtk . ListStore ( str ) # msg_name
self . message_combobox = self . xml . get_widget ( ' message_combobox ' )
self . message_combobox . set_model ( self . message_liststore )
cellrenderertext = gtk . CellRendererText ( )
self . message_combobox . pack_start ( cellrenderertext , True )
self . message_combobox . add_attribute ( cellrenderertext , ' text ' , 0 )
for msg_name in sorted_keys_list :
self . message_liststore . append ( ( msg_name , ) )
2005-04-04 16:46:35 +00:00
self . xml . signal_autoconnect ( self )
self . window . show_all ( )
2004-05-15 16:50:38 +00:00
def run ( self ) :
2005-10-09 22:24:18 +00:00
''' Wait for OK or Cancel button to be pressed and return status messsage
( None if users pressed Cancel or x button of WM '''
2005-03-02 12:46:37 +00:00
rep = self . window . run ( )
2004-05-15 16:50:38 +00:00
if rep == gtk . RESPONSE_OK :
2005-03-02 12:46:37 +00:00
beg , end = self . message_buffer . get_bounds ( )
2006-03-07 14:02:45 +00:00
message = self . message_buffer . get_text ( beg , end ) . decode ( ' utf-8 ' ) \
. strip ( )
2005-07-02 12:43:36 +00:00
msg = helpers . to_one_line ( message )
2005-10-09 14:44:52 +00:00
if self . show :
gajim . config . set ( ' last_status_msg_ ' + self . show , msg )
2004-05-15 16:50:38 +00:00
else :
2005-10-09 22:24:18 +00:00
message = None # user pressed Cancel button or X wm button
2005-03-02 12:46:37 +00:00
self . window . destroy ( )
return message
2004-10-25 22:02:16 +00:00
2006-03-07 14:02:45 +00:00
def on_message_combobox_changed ( self , widget ) :
2004-10-25 22:02:16 +00:00
model = widget . get_model ( )
active = widget . get_active ( )
if active < 0 :
return None
2005-08-26 00:52:44 +00:00
name = model [ active ] [ 0 ] . decode ( ' utf-8 ' )
2006-03-07 14:02:45 +00:00
self . message_buffer . set_text ( self . preset_messages_dict [ name ] )
2004-05-15 16:50:38 +00:00
2005-03-16 01:27:37 +00:00
def on_change_status_message_dialog_key_press_event ( self , widget , event ) :
2005-03-18 01:28:59 +00:00
if event . keyval == gtk . keysyms . Return or \
2005-03-18 01:25:11 +00:00
event . keyval == gtk . keysyms . KP_Enter : # catch CTRL+ENTER
2005-01-08 14:40:08 +00:00
if ( event . state & gtk . gdk . CONTROL_MASK ) :
2005-03-02 12:46:37 +00:00
self . window . response ( gtk . RESPONSE_OK )
2005-04-04 16:46:35 +00:00
2006-01-26 17:40:11 +00:00
def toggle_sensitiviy_of_save_as_preset ( self , widget ) :
btn = self . xml . get_widget ( ' save_as_preset_button ' )
if self . message_buffer . get_char_count ( ) == 0 :
btn . set_sensitive ( False )
else :
btn . set_sensitive ( True )
2006-03-07 14:02:45 +00:00
def on_save_as_preset_button_clicked ( self , widget ) :
start_iter , finish_iter = self . message_buffer . get_bounds ( )
status_message_to_save_as_preset = self . message_buffer . get_text (
start_iter , finish_iter )
dlg = InputDialog ( _ ( ' Save as Preset Status Message ' ) ,
_ ( ' Please type a name for this status message ' ) , is_modal = True )
response = dlg . get_response ( )
if response == gtk . RESPONSE_OK :
msg_name = dlg . input_entry . get_text ( )
msg_text = helpers . to_one_line ( status_message_to_save_as_preset )
2006-03-15 16:34:52 +00:00
if not msg_name : # msg_name was ''
msg_name = msg_text
iter_ = self . message_liststore . append ( ( msg_name , ) )
2006-03-07 14:02:45 +00:00
gajim . config . add_per ( ' statusmsg ' , msg_name )
gajim . config . set_per ( ' statusmsg ' , msg_name , ' message ' , msg_text )
self . preset_messages_dict [ msg_name ] = msg_text
# select in combobox the one we just saved
self . message_combobox . set_active_iter ( iter_ )
2006-01-26 17:40:11 +00:00
2005-06-10 21:14:16 +00:00
class AddNewContactWindow :
''' Class for AddNewContactWindow '''
2005-10-20 11:17:17 +00:00
def __init__ ( self , account , jid = None ) :
2005-04-04 16:46:35 +00:00
self . account = account
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' add_new_contact_window ' , APP )
self . window = self . xml . get_widget ( ' add_new_contact_window ' )
2005-05-04 17:44:49 +00:00
self . uid_entry = self . xml . get_widget ( ' uid_entry ' )
self . protocol_combobox = self . xml . get_widget ( ' protocol_combobox ' )
self . jid_entry = self . xml . get_widget ( ' jid_entry ' )
self . nickname_entry = self . xml . get_widget ( ' nickname_entry ' )
2005-06-13 13:19:54 +00:00
if len ( gajim . connections ) > = 2 :
prompt_text = \
_ ( ' Please fill in the data of the contact you want to add in account %s ' ) % account
else :
prompt_text = _ ( ' Please fill in the data of the contact you want to add ' )
self . xml . get_widget ( ' prompt_label ' ) . set_text ( prompt_text )
2005-04-04 16:46:35 +00:00
self . old_uid_value = ' '
2005-06-13 13:19:54 +00:00
liststore = gtk . ListStore ( str , str )
2005-04-04 16:46:35 +00:00
liststore . append ( [ ' Jabber ' , ' ' ] )
self . agents = [ ' Jabber ' ]
jid_agents = [ ]
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 20:06:26 +00:00
for j in gajim . contacts . get_jid_list ( account ) :
contact = gajim . contacts . get_first_contact_from_jid ( account , j )
if _ ( ' Transports ' ) in contact . groups and contact . show != ' offline ' and \
contact . show != ' error ' :
2005-04-04 16:46:35 +00:00
jid_agents . append ( j )
for a in jid_agents :
if a . find ( ' aim ' ) > - 1 :
name = ' AIM '
elif a . find ( ' icq ' ) > - 1 :
name = ' ICQ '
elif a . find ( ' msn ' ) > - 1 :
name = ' MSN '
elif a . find ( ' yahoo ' ) > - 1 :
name = ' Yahoo! '
else :
name = a
iter = liststore . append ( [ name , a ] )
self . agents . append ( name )
2005-05-04 17:44:49 +00:00
self . protocol_combobox . set_model ( liststore )
self . protocol_combobox . set_active ( 0 )
2005-04-04 16:46:35 +00:00
self . fill_jid ( )
if jid :
2005-05-04 17:44:49 +00:00
self . jid_entry . set_text ( jid )
2005-11-07 21:40:01 +00:00
self . uid_entry . set_sensitive ( False )
2005-04-04 16:46:35 +00:00
jid_splited = jid . split ( ' @ ' )
if jid_splited [ 1 ] in jid_agents :
2005-04-25 20:41:29 +00:00
uid = jid_splited [ 0 ] . replace ( ' % ' , ' @ ' )
2005-05-04 17:44:49 +00:00
self . uid_entry . set_text ( uid )
2006-02-03 18:43:18 +00:00
self . protocol_combobox . set_active ( jid_agents . index ( jid_splited [ 1 ] ) \
+ 1 )
2005-04-25 20:41:29 +00:00
else :
2005-05-04 17:44:49 +00:00
self . uid_entry . set_text ( jid )
self . protocol_combobox . set_active ( 0 )
2005-04-25 20:41:29 +00:00
self . set_nickname ( )
2005-11-07 21:30:35 +00:00
self . nickname_entry . grab_focus ( )
2005-04-04 16:46:35 +00:00
self . group_comboboxentry = self . xml . get_widget ( ' group_comboboxentry ' )
liststore = gtk . ListStore ( str )
self . group_comboboxentry . set_model ( liststore )
2005-07-18 21:08:31 +00:00
for g in gajim . groups [ account ] . keys ( ) :
2006-03-30 21:35:43 +00:00
if g not in helpers . special_groups :
2005-04-04 16:46:35 +00:00
self . group_comboboxentry . append_text ( g )
2005-08-27 00:23:44 +00:00
if not jid_agents :
2005-11-02 14:54:25 +00:00
# There are no transports, so hide the protocol combobox and label
2005-08-27 00:23:44 +00:00
self . protocol_combobox . hide ( )
self . protocol_combobox . set_no_show_all ( True )
protocol_label = self . xml . get_widget ( ' protocol_label ' )
protocol_label . hide ( )
protocol_label . set_no_show_all ( True )
2005-03-02 12:46:37 +00:00
self . xml . signal_autoconnect ( self )
2005-04-04 15:51:29 +00:00
self . window . show_all ( )
2004-05-15 16:50:38 +00:00
2005-04-28 13:01:47 +00:00
def on_add_new_contact_window_key_press_event ( self , widget , event ) :
if event . keyval == gtk . keysyms . Escape : # ESCAPE
self . window . destroy ( )
2005-02-28 23:44:52 +00:00
def on_cancel_button_clicked ( self , widget ) :
2005-04-18 12:17:43 +00:00
''' When Cancel button is clicked '''
2005-04-12 15:30:09 +00:00
self . window . destroy ( )
2004-05-15 16:50:38 +00:00
2005-02-28 23:44:52 +00:00
def on_subscribe_button_clicked ( self , widget ) :
2005-04-18 12:17:43 +00:00
''' When Subscribe button is clicked '''
2005-08-26 00:52:44 +00:00
jid = self . jid_entry . get_text ( ) . decode ( ' utf-8 ' )
nickname = self . nickname_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-02-28 23:44:52 +00:00
if not jid :
2004-11-18 19:22:33 +00:00
return
2005-11-02 14:54:25 +00:00
2005-11-03 14:46:56 +00:00
# check if jid is conform to RFC and stringprep it
try :
jid = helpers . parse_jid ( jid )
except helpers . InvalidFormat , s :
2005-11-02 14:54:25 +00:00
pritext = _ ( ' Invalid User ID ' )
2006-04-02 16:11:21 +00:00
ErrorDialog ( pritext , str ( s ) )
2004-11-18 19:22:33 +00:00
return
2005-11-02 12:46:57 +00:00
2006-03-12 20:53:28 +00:00
# No resource in jid
if jid . find ( ' / ' ) > = 0 :
pritext = _ ( ' Invalid User ID ' )
2006-04-02 16:11:21 +00:00
ErrorDialog ( pritext , _ ( ' The user ID must not contain a resource. ' ) )
2006-03-12 20:53:28 +00:00
return
2005-11-03 14:46:56 +00:00
# Check if jid is already in roster
2006-03-30 17:55:25 +00:00
if jid in gajim . contacts . get_jid_list ( self . account ) :
c = gajim . contacts . get_first_contact_from_jid ( self . account , jid )
if _ ( ' Not in Roster ' ) not in c . groups and c . sub in ( ' both ' , ' to ' ) :
ErrorDialog ( _ ( ' Contact already in roster ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' This contact is already listed in your roster. ' ) )
2006-03-30 17:55:25 +00:00
return
2005-11-02 12:46:57 +00:00
2005-02-28 23:44:52 +00:00
message_buffer = self . xml . get_widget ( ' message_textview ' ) . get_buffer ( )
start_iter = message_buffer . get_start_iter ( )
end_iter = message_buffer . get_end_iter ( )
2005-10-09 22:24:18 +00:00
message = message_buffer . get_text ( start_iter , end_iter ) . decode ( ' utf-8 ' )
2005-08-26 00:52:44 +00:00
group = self . group_comboboxentry . child . get_text ( ) . decode ( ' utf-8 ' )
2006-03-08 10:46:36 +00:00
auto_auth = self . xml . get_widget ( ' auto_authorize_checkbutton ' ) . get_active ( )
2005-10-20 11:17:17 +00:00
gajim . interface . roster . req_sub ( self , jid , message , self . account ,
2006-03-08 10:46:36 +00:00
group = group , pseudo = nickname , auto_auth = auto_auth )
2005-04-12 15:30:09 +00:00
self . window . destroy ( )
2004-05-15 16:50:38 +00:00
2005-02-28 23:44:52 +00:00
def fill_jid ( self ) :
2005-05-04 17:44:49 +00:00
model = self . protocol_combobox . get_model ( )
index = self . protocol_combobox . get_active ( )
2005-08-26 00:52:44 +00:00
jid = self . uid_entry . get_text ( ) . decode ( ' utf-8 ' ) . strip ( )
2005-05-04 17:44:49 +00:00
if index > 0 : # it's not jabber but a transport
2005-02-28 23:44:52 +00:00
jid = jid . replace ( ' @ ' , ' % ' )
2005-08-26 00:52:44 +00:00
agent = model [ index ] [ 1 ] . decode ( ' utf-8 ' )
2005-02-03 22:21:55 +00:00
if agent :
2005-02-28 23:44:52 +00:00
jid + = ' @ ' + agent
2005-05-04 17:44:49 +00:00
self . jid_entry . set_text ( jid )
2005-02-03 22:21:55 +00:00
2005-03-23 13:25:48 +00:00
def on_protocol_combobox_changed ( self , widget ) :
2005-02-28 23:44:52 +00:00
self . fill_jid ( )
2005-02-03 22:21:55 +00:00
def guess_agent ( self ) :
2005-08-26 00:52:44 +00:00
uid = self . uid_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-05-04 17:44:49 +00:00
model = self . protocol_combobox . get_model ( )
2005-02-03 22:21:55 +00:00
#If login contains only numbers, it's probably an ICQ number
2005-05-04 17:44:49 +00:00
if uid . isdigit ( ) :
2005-02-03 22:21:55 +00:00
if ' ICQ ' in self . agents :
2005-05-04 17:44:49 +00:00
self . protocol_combobox . set_active ( self . agents . index ( ' ICQ ' ) )
2005-02-03 22:21:55 +00:00
return
2005-02-04 07:58:40 +00:00
2005-02-28 23:44:52 +00:00
def set_nickname ( self ) :
2005-08-26 00:52:44 +00:00
uid = self . uid_entry . get_text ( ) . decode ( ' utf-8 ' )
nickname = self . nickname_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-02-28 23:44:52 +00:00
if nickname == self . old_uid_value :
2005-05-04 17:44:49 +00:00
self . nickname_entry . set_text ( uid . split ( ' @ ' ) [ 0 ] )
2005-02-03 22:21:55 +00:00
2005-02-28 23:44:52 +00:00
def on_uid_entry_changed ( self , widget ) :
2005-08-26 00:52:44 +00:00
uid = self . uid_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-02-04 07:58:40 +00:00
self . guess_agent ( )
2005-02-28 23:44:52 +00:00
self . set_nickname ( )
self . fill_jid ( )
self . old_uid_value = uid . split ( ' @ ' ) [ 0 ]
2004-05-15 16:50:38 +00:00
2005-06-09 23:28:07 +00:00
class AboutDialog :
2005-04-18 12:17:43 +00:00
''' Class for about dialog '''
2005-04-04 16:46:35 +00:00
def __init__ ( self ) :
2005-03-09 21:29:20 +00:00
dlg = gtk . AboutDialog ( )
dlg . set_name ( ' Gajim ' )
2005-04-16 17:03:21 +00:00
dlg . set_version ( gajim . version )
2006-03-15 12:59:01 +00:00
s = u ' Copyright © 2003-2006 Gajim Team '
2005-03-16 02:16:29 +00:00
dlg . set_copyright ( s )
2005-04-16 17:03:21 +00:00
text = open ( ' ../COPYING ' ) . read ( )
2005-03-16 02:16:29 +00:00
dlg . set_license ( text )
2005-03-09 21:29:20 +00:00
2005-10-30 16:16:00 +00:00
dlg . set_comments ( _ ( ' A GTK+ jabber client ' ) )
2005-03-09 21:29:20 +00:00
dlg . set_website ( ' http://www.gajim.org ' )
2005-03-18 00:47:50 +00:00
2005-09-24 21:50:58 +00:00
authors = [
2005-12-09 17:57:09 +00:00
' Current Developers: ' ,
2005-09-24 21:50:58 +00:00
' Yann Le Boulanger <asterix@lagaule.org> ' ,
' Nikos Kouremenos <kourem@gmail.com> ' ,
' Dimitur Kirov <dkirov@gmail.com> ' ,
2005-11-13 01:48:48 +00:00
' Travis Shirk <travis@pobox.com> ' ,
2005-12-09 17:57:09 +00:00
' ' ,
2006-03-15 12:59:01 +00:00
_ ( ' Past Developers: ' ) ,
' Vincent Hanquez <tab@snarc.org> ' ,
2006-01-12 08:50:07 +00:00
' ' ,
_ ( ' THANKS: ' ) ,
2005-09-24 21:50:58 +00:00
]
2006-01-12 08:50:07 +00:00
text = open ( ' ../THANKS ' ) . read ( )
text_splitted = text . split ( ' \n ' )
text = ' \n ' . join ( text_splitted [ : - 2 ] ) # remove one english setence
# and add it manually as translatable
2006-03-15 12:59:01 +00:00
text + = ' \n %s \n ' % _ ( ' Last but not least, we would like to thank all '
' the package maintainers. ' )
2006-01-12 08:50:07 +00:00
authors . append ( text )
2005-09-24 21:50:58 +00:00
2005-03-16 02:16:29 +00:00
dlg . set_authors ( authors )
2005-09-26 13:06:11 +00:00
if gtk . pygtk_version > = ( 2 , 8 , 0 ) and gtk . gtk_version > = ( 2 , 8 , 0 ) :
dlg . props . wrap_license = True
2005-06-03 11:41:02 +00:00
2005-09-24 21:50:58 +00:00
pixbuf = gtk . gdk . pixbuf_new_from_file ( os . path . join (
2005-12-09 17:57:09 +00:00
gajim . DATA_DIR , ' pixmaps ' , ' gajim_about.png ' ) )
2005-06-03 11:41:02 +00:00
dlg . set_logo ( pixbuf )
2005-09-24 21:49:28 +00:00
#here you write your name in the form Name FamilyName <someone@somewhere>
2005-08-13 11:17:49 +00:00
dlg . set_translator_credits ( _ ( ' translator-credits ' ) )
2005-08-28 15:55:50 +00:00
2006-03-15 12:59:01 +00:00
artists = [ ' Anders Ström ' , ' Christophe Got ' , ' Dennis Craven ' ,
' Guillaume Morin ' , ' Membris Khan ' ]
2005-08-28 15:55:50 +00:00
dlg . set_artists ( artists )
2005-03-09 21:29:20 +00:00
2005-05-12 00:00:40 +00:00
rep = dlg . run ( )
2005-03-12 23:48:08 +00:00
dlg . destroy ( )
2004-05-15 16:50:38 +00:00
2005-06-07 01:10:24 +00:00
class Dialog ( gtk . Dialog ) :
2005-06-12 17:36:27 +00:00
def __init__ ( self , parent , title , buttons , default = None ) :
gtk . Dialog . __init__ ( self , title , parent , gtk . DIALOG_DESTROY_WITH_PARENT | gtk . DIALOG_MODAL | gtk . DIALOG_NO_SEPARATOR )
2005-06-07 01:10:24 +00:00
2005-06-12 17:36:27 +00:00
self . set_border_width ( 6 )
self . vbox . set_spacing ( 12 )
self . set_resizable ( False )
2005-06-07 01:10:24 +00:00
2005-06-12 17:36:27 +00:00
for stock , response in buttons :
self . add_button ( stock , response )
2005-06-07 01:10:24 +00:00
2005-06-12 17:36:27 +00:00
if default is not None :
self . set_default_response ( default )
else :
self . set_default_response ( buttons [ - 1 ] [ 1 ] )
2005-06-07 01:10:24 +00:00
2005-06-12 17:36:27 +00:00
def get_button ( self , index ) :
buttons = self . action_area . get_children ( )
return index < len ( buttons ) and buttons [ index ] or None
2005-06-07 01:10:24 +00:00
2006-04-07 14:23:21 +00:00
2005-09-09 20:21:14 +00:00
class HigDialog ( gtk . MessageDialog ) :
2006-04-02 16:11:21 +00:00
def __init__ ( self , parent , type , buttons , pritext , sectext ,
on_response_ok = None , on_response_cancel = None , on_response_yes = None ,
on_response_no = None ) :
2005-09-09 19:42:47 +00:00
gtk . MessageDialog . __init__ ( self , parent ,
gtk . DIALOG_DESTROY_WITH_PARENT | gtk . DIALOG_MODAL ,
2005-09-22 15:15:39 +00:00
type , buttons , message_format = pritext )
2005-09-09 19:42:47 +00:00
2005-09-22 15:15:39 +00:00
self . format_secondary_text ( sectext )
2005-09-09 19:42:47 +00:00
2006-04-02 16:11:21 +00:00
buttons = self . action_area . get_children ( )
2006-04-07 14:23:21 +00:00
possible_responses = { gtk . STOCK_OK : on_response_ok ,
2006-04-02 16:11:21 +00:00
gtk . STOCK_CANCEL : on_response_cancel , gtk . STOCK_YES : on_response_yes ,
gtk . STOCK_NO : on_response_no }
for b in buttons :
2006-04-07 14:23:21 +00:00
for response in possible_responses :
2006-04-02 16:11:21 +00:00
if b . get_label ( ) == response :
2006-04-07 14:23:21 +00:00
if not possible_responses [ response ] :
2006-04-02 16:11:21 +00:00
b . connect ( ' clicked ' , self . just_destroy )
2006-04-07 14:23:21 +00:00
elif isinstance ( possible_responses [ response ] , tuple ) :
2006-04-08 10:34:47 +00:00
if len ( possible_responses [ response ] ) == 1 :
2006-04-07 14:23:21 +00:00
b . connect ( ' clicked ' , possible_responses [ response ] [ 0 ] )
2006-04-02 16:11:21 +00:00
else :
2006-04-07 14:23:21 +00:00
b . connect ( ' clicked ' , * possible_responses [ response ] )
2006-04-02 16:11:21 +00:00
else :
2006-04-07 14:23:21 +00:00
b . connect ( ' clicked ' , possible_responses [ response ] )
2006-04-02 16:11:21 +00:00
break
def just_destroy ( self , widget ) :
self . destroy ( )
def popup ( self ) :
2006-04-07 14:23:21 +00:00
''' show dialog '''
vb = self . get_children ( ) [ 0 ] . get_children ( ) [ 0 ] # Give focus to top vbox
2006-04-02 16:11:21 +00:00
vb . set_flags ( gtk . CAN_FOCUS )
vb . grab_focus ( )
self . show_all ( )
2005-09-09 19:42:47 +00:00
def get_response ( self ) :
2006-04-02 16:11:21 +00:00
''' Be carefull: this function uses dialog.run() function so GUI is not updated '''
2006-02-21 11:21:58 +00:00
# Give focus to top vbox
vb = self . get_children ( ) [ 0 ] . get_children ( ) [ 0 ]
vb . set_flags ( gtk . CAN_FOCUS )
vb . grab_focus ( )
2005-09-09 19:42:47 +00:00
self . show_all ( )
2005-09-11 15:02:22 +00:00
response = self . run ( )
2005-09-09 19:42:47 +00:00
self . destroy ( )
return response
2006-04-07 14:23:21 +00:00
class FileChooserDialog ( gtk . FileChooserDialog ) :
''' Non-blocking FileChooser Dialog around gtk.FileChooserDialog '''
def __init__ ( self , title_text , action , buttons , default_response ,
select_multiple , current_folder , on_response_ok = None ,
on_response_cancel = None ) :
gtk . FileChooserDialog . __init__ ( self , title = title_text ,
action = action , buttons = buttons )
self . set_default_response ( default_response )
self . set_select_multiple ( select_multiple )
if current_folder and os . path . isdir ( current_folder ) :
self . set_current_folder ( current_folder )
else :
self . set_current_folder ( helpers . get_documents_path ( ) )
self . show_all ( )
2005-09-09 20:21:14 +00:00
class ConfirmationDialog ( HigDialog ) :
2005-10-13 19:44:09 +00:00
''' HIG compliant confirmation dialog. '''
2006-04-02 16:11:21 +00:00
def __init__ ( self , pritext , sectext = ' ' , on_response_ok = None ,
on_response_cancel = None ) :
2005-09-09 20:21:14 +00:00
HigDialog . __init__ ( self , None ,
2006-04-02 16:11:21 +00:00
gtk . MESSAGE_QUESTION , gtk . BUTTONS_OK_CANCEL , pritext , sectext ,
on_response_ok , on_response_cancel )
self . popup ( )
2006-02-21 11:21:58 +00:00
2005-09-09 20:21:14 +00:00
class WarningDialog ( HigDialog ) :
2005-09-09 19:42:47 +00:00
def __init__ ( self , pritext , sectext = ' ' ) :
2005-10-13 19:44:09 +00:00
''' HIG compliant warning dialog. '''
2005-09-09 20:21:14 +00:00
HigDialog . __init__ ( self , None ,
2006-04-02 16:11:21 +00:00
gtk . MESSAGE_WARNING , gtk . BUTTONS_OK , pritext , sectext )
self . popup ( )
2005-09-09 19:42:47 +00:00
2005-09-09 20:21:14 +00:00
class InformationDialog ( HigDialog ) :
2005-09-09 19:42:47 +00:00
def __init__ ( self , pritext , sectext = ' ' ) :
2005-10-13 19:44:09 +00:00
''' HIG compliant info dialog. '''
2005-09-09 20:21:14 +00:00
HigDialog . __init__ ( self , None ,
2006-04-02 16:11:21 +00:00
gtk . MESSAGE_INFO , gtk . BUTTONS_OK , pritext , sectext )
self . popup ( )
2005-09-09 19:42:47 +00:00
2005-09-09 20:21:14 +00:00
class ErrorDialog ( HigDialog ) :
2005-09-09 19:42:47 +00:00
def __init__ ( self , pritext , sectext = ' ' ) :
2005-10-13 19:44:09 +00:00
''' HIG compliant error dialog. '''
2005-09-09 20:21:14 +00:00
HigDialog . __init__ ( self , None ,
2006-04-02 16:11:21 +00:00
gtk . MESSAGE_ERROR , gtk . BUTTONS_OK , pritext , sectext )
self . popup ( )
2005-09-09 19:42:47 +00:00
2006-02-06 21:35:54 +00:00
class YesNoDialog ( HigDialog ) :
2006-04-02 16:11:21 +00:00
def __init__ ( self , pritext , sectext = ' ' , on_response_yes = None ,
on_response_no = None ) :
2006-02-06 21:35:54 +00:00
''' HIG compliant YesNo dialog. '''
HigDialog . __init__ ( self , None ,
2006-04-02 16:11:21 +00:00
gtk . MESSAGE_QUESTION , gtk . BUTTONS_YES_NO , pritext , sectext ,
on_response_yes = on_response_yes , on_response_no = on_response_no )
2006-04-06 11:04:41 +00:00
self . popup ( )
2006-02-06 21:35:54 +00:00
2005-07-29 17:18:51 +00:00
class ConfirmationDialogCheck ( ConfirmationDialog ) :
''' HIG compliant confirmation dialog with checkbutton. '''
2006-04-02 16:11:21 +00:00
def __init__ ( self , pritext , sectext = ' ' , checktext = ' ' ,
on_response_ok = None , on_response_cancel = None ) :
HigDialog . __init__ ( self , None , gtk . MESSAGE_QUESTION ,
gtk . BUTTONS_OK_CANCEL , pritext , sectext , on_response_ok ,
on_response_cancel )
2005-09-11 14:21:14 +00:00
self . set_default_response ( gtk . RESPONSE_OK )
2006-02-21 11:21:58 +00:00
2005-09-11 18:05:18 +00:00
ok_button = self . action_area . get_children ( ) [ 0 ] # right to left
ok_button . grab_focus ( )
2006-02-21 11:21:58 +00:00
2005-07-29 17:18:51 +00:00
self . checkbutton = gtk . CheckButton ( checktext )
2005-08-24 11:57:14 +00:00
self . vbox . pack_start ( self . checkbutton , expand = False , fill = True )
2006-04-04 14:49:56 +00:00
self . popup ( )
2006-02-21 11:21:58 +00:00
2005-07-29 17:18:51 +00:00
def is_checked ( self ) :
''' Get active state of the checkbutton '''
return self . checkbutton . get_active ( )
Merged revisions 5017-5020,5022-5029 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r5017 | asterix | 2006-01-06 01:55:51 -0700 (Fri, 06 Jan 2006) | 2 lines
use escape for pango markup
........
r5018 | asterix | 2006-01-06 02:21:39 -0700 (Fri, 06 Jan 2006) | 2 lines
missing new contacts function
........
r5019 | asterix | 2006-01-06 11:03:07 -0700 (Fri, 06 Jan 2006) | 2 lines
handle the click on toggle_gpg_encryption menuitem
........
r5020 | asterix | 2006-01-06 11:14:14 -0700 (Fri, 06 Jan 2006) | 2 lines
use the saved size even if a chat window is already opened
........
r5022 | asterix | 2006-01-07 03:43:47 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now resume filetransfert
........
r5023 | asterix | 2006-01-07 03:56:31 -0700 (Sat, 07 Jan 2006) | 2 lines
[Knuckles] Google E-Mail Notification
........
r5024 | asterix | 2006-01-07 04:02:16 -0700 (Sat, 07 Jan 2006) | 2 lines
better string
........
r5025 | asterix | 2006-01-07 04:14:32 -0700 (Sat, 07 Jan 2006) | 2 lines
fix a TB
........
r5026 | asterix | 2006-01-07 05:36:55 -0700 (Sat, 07 Jan 2006) | 2 lines
we can now drag a file on a contact in the roster to send him a file
........
r5027 | asterix | 2006-01-07 06:26:28 -0700 (Sat, 07 Jan 2006) | 2 lines
contact.groups is always a list, even if emtpy
........
r5028 | asterix | 2006-01-07 06:54:30 -0700 (Sat, 07 Jan 2006) | 2 lines
make all buttons insensitive on a category row in disco
........
r5029 | asterix | 2006-01-07 07:19:25 -0700 (Sat, 07 Jan 2006) | 2 lines
auto open groupchat configuration window when we create a new room
........
2006-01-07 17:25:35 +00:00
class FTOverwriteConfirmationDialog ( ConfirmationDialog ) :
''' HIG compliant confirmation dialog to overwrite or resume a file transfert '''
def __init__ ( self , pritext , sectext = ' ' , propose_resume = True ) :
HigDialog . __init__ ( self , None , gtk . MESSAGE_QUESTION , gtk . BUTTONS_CANCEL ,
pritext , sectext )
if propose_resume :
b = gtk . Button ( ' ' , gtk . STOCK_REFRESH )
align = b . get_children ( ) [ 0 ]
hbox = align . get_children ( ) [ 0 ]
label = hbox . get_children ( ) [ 1 ]
label . set_text ( ' _Resume ' )
label . set_use_underline ( True )
self . add_action_widget ( b , 100 )
b = gtk . Button ( ' ' , gtk . STOCK_SAVE_AS )
align = b . get_children ( ) [ 0 ]
hbox = align . get_children ( ) [ 0 ]
label = hbox . get_children ( ) [ 1 ]
label . set_text ( ' Re_place ' )
label . set_use_underline ( True )
self . add_action_widget ( b , 200 )
2005-06-10 21:14:16 +00:00
class InputDialog :
2005-05-14 01:29:53 +00:00
''' Class for Input dialog '''
2005-09-09 20:26:06 +00:00
def __init__ ( self , title , label_str , input_str = None , is_modal = True ,
ok_handler = None ) :
2006-03-07 14:02:45 +00:00
# if modal is True you also need to call get_response()
# and ok_handler won't be used
2005-05-14 01:29:53 +00:00
xml = gtk . glade . XML ( GTKGUI_GLADE , ' input_dialog ' , APP )
self . dialog = xml . get_widget ( ' input_dialog ' )
label = xml . get_widget ( ' label ' )
self . input_entry = xml . get_widget ( ' input_entry ' )
self . dialog . set_title ( title )
2006-01-19 13:52:02 +00:00
label . set_markup ( label_str )
2005-05-14 16:34:07 +00:00
if input_str :
self . input_entry . set_text ( input_str )
2005-06-18 23:44:33 +00:00
self . input_entry . select_region ( 0 , - 1 ) # select all
2005-07-25 07:47:05 +00:00
self . is_modal = is_modal
if not is_modal and ok_handler is not None :
self . ok_handler = ok_handler
okbutton = xml . get_widget ( ' okbutton ' )
okbutton . connect ( ' clicked ' , self . on_okbutton_clicked )
2005-07-25 14:21:01 +00:00
cancelbutton = xml . get_widget ( ' cancelbutton ' )
cancelbutton . connect ( ' clicked ' , self . on_cancelbutton_clicked )
2005-07-25 07:47:05 +00:00
self . dialog . show_all ( )
def on_okbutton_clicked ( self , widget ) :
2006-02-04 20:26:07 +00:00
user_input = self . input_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-06-18 23:44:33 +00:00
self . dialog . destroy ( )
2006-02-04 20:26:07 +00:00
self . ok_handler ( user_input )
2005-07-25 14:21:01 +00:00
def on_cancelbutton_clicked ( self , widget ) :
self . dialog . destroy ( )
2005-07-25 07:47:05 +00:00
def get_response ( self ) :
if self . is_modal :
response = self . dialog . run ( )
self . dialog . destroy ( )
2005-06-18 23:44:33 +00:00
return response
2005-06-09 22:29:06 +00:00
2005-06-13 10:48:07 +00:00
class SubscriptionRequestWindow :
2005-10-20 11:17:17 +00:00
def __init__ ( self , jid , text , account ) :
2005-04-04 16:46:35 +00:00
xml = gtk . glade . XML ( GTKGUI_GLADE , ' subscription_request_window ' , APP )
2005-04-12 15:30:09 +00:00
self . window = xml . get_widget ( ' subscription_request_window ' )
2005-04-04 16:46:35 +00:00
self . jid = jid
self . account = account
2005-06-13 13:26:04 +00:00
if len ( gajim . connections ) > = 2 :
prompt_text = _ ( ' Subscription request for account %s from %s ' ) \
% ( account , self . jid )
else :
prompt_text = _ ( ' Subscription request from %s ' ) % self . jid
xml . get_widget ( ' from_label ' ) . set_text ( prompt_text )
2005-04-04 16:46:35 +00:00
xml . get_widget ( ' message_textview ' ) . get_buffer ( ) . set_text ( text )
xml . signal_autoconnect ( self )
self . window . show_all ( )
2005-03-01 14:02:32 +00:00
def on_close_button_clicked ( self , widget ) :
2005-04-12 15:30:09 +00:00
self . window . destroy ( )
2004-05-15 16:50:38 +00:00
2005-03-01 14:02:32 +00:00
def on_authorize_button_clicked ( self , widget ) :
2005-05-16 13:56:46 +00:00
''' accept the request '''
2005-04-14 09:38:08 +00:00
gajim . connections [ self . account ] . send_authorization ( self . jid )
2005-04-12 15:30:09 +00:00
self . window . destroy ( )
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 20:06:26 +00:00
if self . jid not in gajim . contacts . get_jid_list ( self . account ) :
2005-10-20 11:17:17 +00:00
AddNewContactWindow ( self . account , self . jid )
2005-05-18 08:47:38 +00:00
def on_contact_info_button_clicked ( self , widget ) :
''' ask vcard '''
2005-11-13 15:08:47 +00:00
if gajim . interface . instances [ self . account ] [ ' infos ' ] . has_key ( self . jid ) :
gajim . interface . instances [ self . account ] [ ' infos ' ] [ self . jid ] . window . present ( )
2005-05-18 08:47:38 +00:00
else :
2006-02-20 21:30:45 +00:00
contact = gajim . contacts . create_contact ( jid = self . jid , name = ' ' ,
groups = [ ] , show = ' ' , status = ' ' , sub = ' ' , ask = ' ' , resource = ' ' ,
priority = 5 , keyID = ' ' , our_chatstate = None , chatstate = None )
2005-11-13 15:08:47 +00:00
gajim . interface . instances [ self . account ] [ ' infos ' ] [ self . jid ] = \
2006-02-20 21:30:45 +00:00
vcard . VcardWindow ( contact , self . account )
# Remove jabber page
gajim . interface . instances [ self . account ] [ ' infos ' ] [ self . jid ] . xml . \
get_widget ( ' information_notebook ' ) . remove_page ( 0 )
2005-05-18 08:47:38 +00:00
gajim . connections [ self . account ] . request_vcard ( self . jid )
2004-05-15 16:50:38 +00:00
2005-03-01 14:02:32 +00:00
def on_deny_button_clicked ( self , widget ) :
2005-04-18 12:17:43 +00:00
''' refuse the request '''
2005-04-14 09:38:08 +00:00
gajim . connections [ self . account ] . refuse_authorization ( self . jid )
2005-04-12 15:30:09 +00:00
self . window . destroy ( )
2005-04-04 16:46:35 +00:00
2005-06-10 21:14:16 +00:00
class JoinGroupchatWindow :
2005-10-20 11:17:17 +00:00
def __init__ ( self , account , server = ' ' , room = ' ' , nick = ' ' ) :
2005-04-21 18:53:16 +00:00
self . account = account
2005-09-14 07:34:17 +00:00
if nick == ' ' :
nick = gajim . nicks [ self . account ]
2005-04-14 07:20:14 +00:00
if gajim . connections [ account ] . connected < 2 :
2005-06-10 21:14:16 +00:00
ErrorDialog ( _ ( ' You are not connected to the server ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' You can not join a group chat unless you are connected. ' ) )
2005-05-12 00:00:40 +00:00
raise RuntimeError , ' You must be connected to join a groupchat '
2006-01-18 02:16:49 +00:00
self . _empty_required_widgets = [ ]
2005-04-04 16:46:35 +00:00
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' join_groupchat_window ' , APP )
self . window = self . xml . get_widget ( ' join_groupchat_window ' )
self . xml . get_widget ( ' server_entry ' ) . set_text ( server )
self . xml . get_widget ( ' room_entry ' ) . set_text ( room )
2005-09-14 07:34:17 +00:00
self . xml . get_widget ( ' nickname_entry ' ) . set_text ( nick )
2005-04-04 16:46:35 +00:00
self . xml . signal_autoconnect ( self )
2005-11-13 15:08:47 +00:00
gajim . interface . instances [ account ] [ ' join_gc ' ] = self #now add us to open windows
2005-04-21 18:53:16 +00:00
if len ( gajim . connections ) > 1 :
2005-11-28 16:29:04 +00:00
title = _ ( ' Join Group Chat with account %s ' ) % account
2005-04-21 18:53:16 +00:00
else :
2005-08-01 22:48:58 +00:00
title = _ ( ' Join Group Chat ' )
2005-04-21 18:53:16 +00:00
self . window . set_title ( title )
2005-04-06 22:52:48 +00:00
self . recently_combobox = self . xml . get_widget ( ' recently_combobox ' )
liststore = gtk . ListStore ( str )
self . recently_combobox . set_model ( liststore )
cell = gtk . CellRendererText ( )
self . recently_combobox . pack_start ( cell , True )
self . recently_combobox . add_attribute ( cell , ' text ' , 0 )
2005-04-12 21:09:06 +00:00
self . recently_groupchat = gajim . config . get ( ' recently_groupchat ' ) . split ( )
2005-04-06 22:52:48 +00:00
for g in self . recently_groupchat :
self . recently_combobox . append_text ( g )
2005-11-25 22:28:51 +00:00
if len ( self . recently_groupchat ) == 0 :
self . recently_combobox . set_sensitive ( False )
2006-02-26 23:29:49 +00:00
elif server == ' ' and room == ' ' :
2005-06-10 12:31:06 +00:00
self . recently_combobox . set_active ( 0 )
self . xml . get_widget ( ' room_entry ' ) . select_region ( 0 , - 1 )
2005-11-25 22:45:58 +00:00
elif room and server :
self . xml . get_widget ( ' join_button ' ) . grab_focus ( )
2005-04-06 22:52:48 +00:00
2006-01-14 21:59:59 +00:00
self . _server_entry = self . xml . get_widget ( ' server_entry ' )
self . _room_entry = self . xml . get_widget ( ' room_entry ' )
self . _nickname_entry = self . xml . get_widget ( ' nickname_entry ' )
if not self . _server_entry . get_text ( ) :
self . _empty_required_widgets . append ( self . _server_entry )
if not self . _room_entry . get_text ( ) :
self . _empty_required_widgets . append ( self . _room_entry )
if not self . _nickname_entry . get_text ( ) :
self . _empty_required_widgets . append ( self . _nickname_entry )
if len ( self . _empty_required_widgets ) :
self . xml . get_widget ( ' join_button ' ) . set_sensitive ( False )
2005-04-04 15:51:29 +00:00
self . window . show_all ( )
2005-03-01 23:48:05 +00:00
2005-03-02 12:32:44 +00:00
def on_join_groupchat_window_destroy ( self , widget ) :
2005-04-18 12:17:43 +00:00
''' close window '''
2005-09-09 20:26:06 +00:00
# remove us from open windows
2005-11-13 15:08:47 +00:00
del gajim . interface . instances [ self . account ] [ ' join_gc ' ]
2005-03-01 23:48:05 +00:00
2005-04-07 09:53:54 +00:00
def on_join_groupchat_window_key_press_event ( self , widget , event ) :
if event . keyval == gtk . keysyms . Escape : # ESCAPE
widget . destroy ( )
2006-01-14 21:59:59 +00:00
def on_required_entry_changed ( self , widget ) :
if not widget . get_text ( ) :
self . _empty_required_widgets . append ( widget )
self . xml . get_widget ( ' join_button ' ) . set_sensitive ( False )
else :
if widget in self . _empty_required_widgets :
self . _empty_required_widgets . remove ( widget )
if len ( self . _empty_required_widgets ) == 0 :
self . xml . get_widget ( ' join_button ' ) . set_sensitive ( True )
2005-11-25 22:23:58 +00:00
def on_room_entry_key_press_event ( self , widget , event ) :
# Check for pressed @ and jump to server_entry if found
if event . keyval == gtk . keysyms . at :
self . xml . get_widget ( ' server_entry ' ) . grab_focus ( )
return True
def on_server_entry_key_press_event ( self , widget , event ) :
# If backspace is pressed in empty server_entry, return to the room entry
backspace = event . keyval == gtk . keysyms . BackSpace
server_entry = self . xml . get_widget ( ' server_entry ' )
empty = len ( server_entry . get_text ( ) ) == 0
if backspace and empty :
self . xml . get_widget ( ' room_entry ' ) . grab_focus ( )
return True
2005-04-06 22:52:48 +00:00
def on_recently_combobox_changed ( self , widget ) :
model = widget . get_model ( )
iter = widget . get_active_iter ( )
2005-08-26 00:52:44 +00:00
gid = model [ iter ] [ 0 ] . decode ( ' utf-8 ' )
2005-04-06 22:52:48 +00:00
self . xml . get_widget ( ' room_entry ' ) . set_text ( gid . split ( ' @ ' ) [ 0 ] )
self . xml . get_widget ( ' server_entry ' ) . set_text ( gid . split ( ' @ ' ) [ 1 ] )
2005-03-04 13:41:48 +00:00
def on_cancel_button_clicked ( self , widget ) :
2005-04-18 12:17:43 +00:00
''' When Cancel button is clicked '''
2005-04-12 15:30:09 +00:00
self . window . destroy ( )
2005-03-01 23:48:05 +00:00
2005-03-02 12:32:44 +00:00
def on_join_button_clicked ( self , widget ) :
2005-04-18 12:17:43 +00:00
''' When Join button is clicked '''
2005-08-26 00:52:44 +00:00
nickname = self . xml . get_widget ( ' nickname_entry ' ) . get_text ( ) . decode ( ' utf-8 ' )
room = self . xml . get_widget ( ' room_entry ' ) . get_text ( ) . decode ( ' utf-8 ' )
server = self . xml . get_widget ( ' server_entry ' ) . get_text ( ) . decode ( ' utf-8 ' )
password = self . xml . get_widget ( ' password_entry ' ) . get_text ( ) . decode ( ' utf-8 ' )
2005-03-01 23:48:05 +00:00
jid = ' %s @ %s ' % ( room , server )
2006-01-19 19:52:51 +00:00
try :
jid = helpers . parse_jid ( jid )
except :
ErrorDialog ( _ ( ' Invalid room or server name ' ) ,
2006-01-19 19:59:58 +00:00
_ ( ' The room name or server name has not allowed characters. ' ) )
return
2005-04-06 22:52:48 +00:00
if jid in self . recently_groupchat :
self . recently_groupchat . remove ( jid )
self . recently_groupchat . insert ( 0 , jid )
if len ( self . recently_groupchat ) > 10 :
self . recently_groupchat = self . recently_groupchat [ 0 : 10 ]
2005-04-12 21:09:06 +00:00
gajim . config . set ( ' recently_groupchat ' , ' ' . join ( self . recently_groupchat ) )
2005-06-13 10:49:48 +00:00
2005-10-20 11:17:17 +00:00
gajim . interface . roster . join_gc_room ( self . account , jid , nickname , password )
2005-06-13 10:49:48 +00:00
2005-04-12 15:30:09 +00:00
self . window . destroy ( )
2005-03-01 23:48:05 +00:00
2005-06-10 21:14:16 +00:00
class NewMessageDialog :
2005-10-20 11:17:17 +00:00
def __init__ ( self , account ) :
2005-03-01 23:48:05 +00:00
self . account = account
2005-06-19 23:09:15 +00:00
2005-04-17 19:53:39 +00:00
if len ( gajim . connections ) > 1 :
2005-11-28 16:29:04 +00:00
title = _ ( ' Start Chat with account %s ' ) % account
2005-04-04 16:46:35 +00:00
else :
2005-11-28 16:29:04 +00:00
title = _ ( ' Start Chat ' )
2005-07-01 15:15:35 +00:00
prompt_text = _ ( ' Fill in the contact ID of the contact you would like \n to send a chat message to: ' )
2005-03-01 23:48:05 +00:00
2005-10-29 14:24:32 +00:00
InputDialog ( title , prompt_text , is_modal = False , ok_handler = self . new_message_response )
2005-07-25 07:47:05 +00:00
def new_message_response ( self , jid ) :
''' called when ok button is clicked '''
2005-08-06 19:14:21 +00:00
if gajim . connections [ self . account ] . connected < = 1 :
#if offline or connecting
ErrorDialog ( _ ( ' Connection not available ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' Please make sure you are connected with " %s " . ' % self . account ) )
2005-08-06 19:14:21 +00:00
return
2005-06-19 23:09:15 +00:00
2005-10-20 11:17:17 +00:00
gajim . interface . roster . new_chat_from_jid ( self . account , jid )
2005-03-01 23:48:05 +00:00
2005-06-10 21:14:16 +00:00
class ChangePasswordDialog :
2005-10-20 11:17:17 +00:00
def __init__ ( self , account ) :
2005-07-18 11:03:53 +00:00
# 'account' can be None if we are about to create our first one
if not account or gajim . connections [ account ] . connected < 2 :
2005-06-10 21:14:16 +00:00
ErrorDialog ( _ ( ' You are not connected to the server ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' Without a connection, you can not change your password. ' ) )
2005-07-18 11:03:53 +00:00
raise RuntimeError , ' You are not connected to the server '
2005-03-01 23:48:05 +00:00
self . account = account
2005-04-04 16:46:35 +00:00
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' change_password_dialog ' , APP )
self . dialog = self . xml . get_widget ( ' change_password_dialog ' )
self . password1_entry = self . xml . get_widget ( ' password1_entry ' )
self . password2_entry = self . xml . get_widget ( ' password2_entry ' )
2005-03-28 01:39:12 +00:00
2005-06-05 10:48:34 +00:00
self . dialog . show_all ( )
2005-03-04 13:10:00 +00:00
def run ( self ) :
2005-04-18 12:17:43 +00:00
''' Wait for OK button to be pressed and return new password '''
2005-03-04 13:10:00 +00:00
end = False
while not end :
rep = self . dialog . run ( )
if rep == gtk . RESPONSE_OK :
2005-08-26 00:52:44 +00:00
password1 = self . password1_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-03-04 13:10:00 +00:00
if not password1 :
2005-08-01 23:17:53 +00:00
ErrorDialog ( _ ( ' Invalid password ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' You must enter a password. ' ) )
2005-03-04 13:10:00 +00:00
continue
2005-08-26 00:52:44 +00:00
password2 = self . password2_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-03-04 13:10:00 +00:00
if password1 != password2 :
2005-08-01 22:48:58 +00:00
ErrorDialog ( _ ( ' Passwords do not match ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' The passwords typed in both fields must be identical. ' ) )
2005-03-04 13:10:00 +00:00
continue
message = password1
else :
message = - 1
end = True
self . dialog . destroy ( )
return message
2005-06-09 22:29:06 +00:00
2005-06-10 18:40:19 +00:00
class PopupNotificationWindow :
2006-04-03 07:40:15 +00:00
def __init__ ( self , event_type , jid , account , msg_type = ' ' ,
path_to_image = None , title = None , text = None ) :
2005-04-12 15:30:09 +00:00
self . account = account
self . jid = jid
2005-07-07 15:41:03 +00:00
self . msg_type = msg_type
2006-04-04 17:46:19 +00:00
2005-04-21 21:23:41 +00:00
xml = gtk . glade . XML ( GTKGUI_GLADE , ' popup_notification_window ' , APP )
self . window = xml . get_widget ( ' popup_notification_window ' )
2005-04-04 19:27:06 +00:00
close_button = xml . get_widget ( ' close_button ' )
2005-04-06 18:51:54 +00:00
event_type_label = xml . get_widget ( ' event_type_label ' )
event_description_label = xml . get_widget ( ' event_description_label ' )
eventbox = xml . get_widget ( ' eventbox ' )
2006-01-18 20:30:24 +00:00
image = xml . get_widget ( ' notification_image ' )
2006-04-04 17:46:19 +00:00
2006-01-20 17:40:45 +00:00
if not text :
2006-01-20 17:50:01 +00:00
text = gajim . get_name_from_jid ( account , jid ) # default value of text
2006-04-03 07:40:15 +00:00
if not title :
title = event_type
2005-10-11 13:59:41 +00:00
2006-04-03 14:21:51 +00:00
event_type_label . set_markup (
' <span foreground= " black " weight= " bold " > %s </span> ' % title )
2005-09-05 00:08:52 +00:00
# set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ]
2005-04-06 18:51:54 +00:00
self . window . modify_bg ( gtk . STATE_NORMAL , gtk . gdk . color_parse ( ' black ' ) )
2006-04-04 17:46:19 +00:00
2006-01-18 20:30:24 +00:00
# default image
2006-01-20 17:40:45 +00:00
if not path_to_image :
path_to_image = os . path . abspath (
os . path . join ( gajim . DATA_DIR , ' pixmaps ' , ' events ' , ' chat_msg_recv.png ' ) ) # img to display
2005-10-11 13:59:41 +00:00
2005-06-03 18:40:43 +00:00
if event_type == _ ( ' Contact Signed In ' ) :
2006-04-05 19:57:13 +00:00
bg_color = ' limegreen '
2005-06-03 18:40:43 +00:00
elif event_type == _ ( ' Contact Signed Out ' ) :
2006-04-05 19:57:13 +00:00
bg_color = ' red '
2005-10-27 13:15:03 +00:00
elif event_type in ( _ ( ' New Message ' ) , _ ( ' New Single Message ' ) ,
2006-04-05 19:57:13 +00:00
_ ( ' New Private Message ' ) , _ ( ' New E-mail ' ) ) :
bg_color = ' dodgerblue '
2005-08-03 16:53:04 +00:00
elif event_type == _ ( ' File Transfer Request ' ) :
2006-04-05 19:57:13 +00:00
bg_color = ' khaki '
2005-08-07 21:01:21 +00:00
elif event_type == _ ( ' File Transfer Error ' ) :
2006-04-05 19:57:13 +00:00
bg_color = ' firebrick '
Merged in trunk updates, including meta_contacts
Merged revisions 4951,4962-4969 via svnmerge from
svn://svn.gajim.org/gajim/trunk
........
r4951 | nk | 2005-12-30 16:50:36 -0700 (Fri, 30 Dec 2005) | 1 line
fixes in greek transl
........
r4962 | asterix | 2006-01-01 11:41:04 -0700 (Sun, 01 Jan 2006) | 2 lines
merge meta_contacts branch with trunk. Meta contacts are not in gajim yet, but framework is here. We now use gajim.contacts.many_functions() to handle contacts and groupchat_contacts.
........
r4963 | asterix | 2006-01-01 11:43:24 -0700 (Sun, 01 Jan 2006) | 2 lines
correct contacts file
........
r4964 | asterix | 2006-01-01 11:47:26 -0700 (Sun, 01 Jan 2006) | 2 lines
dict.remove() doesn't exists, it's del dict[]
........
r4965 | asterix | 2006-01-01 11:50:15 -0700 (Sun, 01 Jan 2006) | 2 lines
some missing commits from branch
........
r4966 | asterix | 2006-01-01 11:53:30 -0700 (Sun, 01 Jan 2006) | 2 lines
end of gc_contact.nick -> gc_contact.name
........
r4967 | asterix | 2006-01-01 12:05:59 -0700 (Sun, 01 Jan 2006) | 2 lines
new ACE option: send_sha_in_gc_presence that allow to send sha info in groupchat presences
........
r4968 | asterix | 2006-01-01 12:12:36 -0700 (Sun, 01 Jan 2006) | 2 lines
0.9.1-2 in debian that solve the group bug (commit [4924])
........
r4969 | asterix | 2006-01-01 12:31:13 -0700 (Sun, 01 Jan 2006) | 2 lines
typo
........
2006-01-01 20:06:26 +00:00
elif event_type in ( _ ( ' File Transfer Completed ' ) ,
_ ( ' File Transfer Stopped ' ) ) :
2006-04-05 19:57:13 +00:00
bg_color = ' yellowgreen '
2006-04-05 16:32:22 +00:00
elif event_type == _ ( ' Groupchat Invitation ' ) :
2006-04-05 19:57:13 +00:00
bg_color = ' tan1 '
2006-04-05 16:32:22 +00:00
else : # Unknown event ! Shouldn't happen but deal with it
2006-04-05 19:57:13 +00:00
bg_color = ' white '
popup_bg_color = gtk . gdk . color_parse ( bg_color )
close_button . modify_bg ( gtk . STATE_NORMAL , popup_bg_color )
eventbox . modify_bg ( gtk . STATE_NORMAL , popup_bg_color )
event_description_label . set_markup (
' <span foreground= " black " > %s </span> ' % text )
2006-01-18 20:30:24 +00:00
# set the image
2006-01-20 17:40:45 +00:00
image . set_from_file ( path_to_image )
2006-01-18 20:30:24 +00:00
2005-04-04 16:46:35 +00:00
# position the window to bottom-right of screen
2005-04-12 15:30:09 +00:00
window_width , self . window_height = self . window . get_size ( )
2005-10-20 11:17:17 +00:00
gajim . interface . roster . popups_notification_height + = self . window_height
2006-01-21 21:11:29 +00:00
pos_x = gajim . config . get ( ' notification_position_x ' )
if pos_x < 0 :
pos_x = gtk . gdk . screen_width ( ) - window_width + pos_x + 1
pos_y = gajim . config . get ( ' notification_position_y ' )
if pos_y < 0 :
pos_y = gtk . gdk . screen_height ( ) - gajim . interface . roster . popups_notification_height + pos_y + 1
self . window . move ( pos_x , pos_y )
2005-09-23 21:01:42 +00:00
2005-04-04 19:27:06 +00:00
xml . signal_autoconnect ( self )
2005-04-04 15:51:29 +00:00
self . window . show_all ( )
2005-12-30 21:37:36 +00:00
timeout = gajim . config . get ( ' notification_timeout ' ) * 1000 # make it ms
gobject . timeout_add ( timeout , self . on_timeout )
2005-04-04 16:46:35 +00:00
2005-04-12 15:30:09 +00:00
def on_close_button_clicked ( self , widget ) :
2005-04-21 21:23:41 +00:00
self . adjust_height_and_move_popup_notification_windows ( )
2005-04-04 19:27:06 +00:00
2005-04-12 15:30:09 +00:00
def on_timeout ( self ) :
2005-04-21 21:23:41 +00:00
self . adjust_height_and_move_popup_notification_windows ( )
2005-09-23 21:01:42 +00:00
2005-04-21 21:23:41 +00:00
def adjust_height_and_move_popup_notification_windows ( self ) :
2005-04-05 15:06:11 +00:00
#remove
2005-10-20 11:17:17 +00:00
gajim . interface . roster . popups_notification_height - = self . window_height
2005-04-04 19:27:06 +00:00
self . window . destroy ( )
2005-09-23 21:01:42 +00:00
2005-10-20 11:17:17 +00:00
if len ( gajim . interface . roster . popup_notification_windows ) > 0 :
2005-04-05 15:06:11 +00:00
# we want to remove the first window added in the list
2005-10-20 11:17:17 +00:00
gajim . interface . roster . popup_notification_windows . pop ( 0 ) # remove 1st item
2005-04-05 15:06:11 +00:00
# move the rest of popup windows
2005-10-20 11:17:17 +00:00
gajim . interface . roster . popups_notification_height = 0
for window_instance in gajim . interface . roster . popup_notification_windows :
2005-04-05 15:06:11 +00:00
window_width , window_height = window_instance . window . get_size ( )
2005-10-20 11:17:17 +00:00
gajim . interface . roster . popups_notification_height + = window_height
2005-05-19 17:47:40 +00:00
window_instance . window . move ( gtk . gdk . screen_width ( ) - window_width ,
2005-10-20 11:17:17 +00:00
gtk . gdk . screen_height ( ) - gajim . interface . roster . popups_notification_height )
2005-04-06 18:51:54 +00:00
2005-04-21 21:23:41 +00:00
def on_popup_notification_window_button_press_event ( self , widget , event ) :
2005-11-26 14:39:27 +00:00
if event . button != 1 :
self . window . destroy ( )
return
2006-04-06 18:13:06 +00:00
gajim . interface . handle_event ( self . account , self . jid , self . msg_type )
2005-04-21 21:23:41 +00:00
self . adjust_height_and_move_popup_notification_windows ( )
2005-07-01 15:15:35 +00:00
2005-07-05 21:35:37 +00:00
class SingleMessageWindow :
''' SingleMessageWindow can send or show a received
2006-03-08 01:27:01 +00:00
singled message depending on action argument which can be ' send '
or ' receive ' .
'''
2005-10-20 11:17:17 +00:00
def __init__ ( self , account , to = ' ' , action = ' ' , from_whom = ' ' ,
2005-11-23 18:19:22 +00:00
subject = ' ' , message = ' ' , resource = ' ' ) :
2005-07-01 15:15:35 +00:00
self . account = account
2005-07-05 21:35:37 +00:00
self . action = action
self . subject = subject
self . message = message
2005-12-08 14:51:35 +00:00
self . to = to
self . from_whom = from_whom
self . resource = resource
2005-07-01 15:15:35 +00:00
2005-07-05 21:35:37 +00:00
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' single_message_window ' , APP )
self . window = self . xml . get_widget ( ' single_message_window ' )
2005-07-02 15:49:25 +00:00
self . count_chars_label = self . xml . get_widget ( ' count_chars_label ' )
2005-07-05 21:35:37 +00:00
self . from_label = self . xml . get_widget ( ' from_label ' )
self . from_entry = self . xml . get_widget ( ' from_entry ' )
self . to_label = self . xml . get_widget ( ' to_label ' )
2005-07-02 15:49:25 +00:00
self . to_entry = self . xml . get_widget ( ' to_entry ' )
self . subject_entry = self . xml . get_widget ( ' subject_entry ' )
2005-12-12 09:12:29 +00:00
self . message_scrolledwindow = self . xml . get_widget (
' message_scrolledwindow ' )
2005-07-05 21:35:37 +00:00
self . message_textview = self . xml . get_widget ( ' message_textview ' )
self . message_tv_buffer = self . message_textview . get_buffer ( )
2005-12-12 09:12:29 +00:00
self . conversation_scrolledwindow = self . xml . get_widget (
' conversation_scrolledwindow ' )
self . conversation_textview = conversation_textview . ConversationTextview (
account )
self . conversation_textview . show ( )
self . conversation_tv_buffer = self . conversation_textview . get_buffer ( )
self . xml . get_widget ( ' conversation_scrolledwindow ' ) . add (
self . conversation_textview )
2005-07-05 21:35:37 +00:00
self . send_button = self . xml . get_widget ( ' send_button ' )
self . reply_button = self . xml . get_widget ( ' reply_button ' )
2005-07-05 23:55:33 +00:00
self . send_and_close_button = self . xml . get_widget ( ' send_and_close_button ' )
2005-12-08 14:51:35 +00:00
self . cancel_button = self . xml . get_widget ( ' cancel_button ' )
self . close_button = self . xml . get_widget ( ' close_button ' )
2005-07-02 15:49:25 +00:00
self . message_tv_buffer . connect ( ' changed ' , self . update_char_counter )
2005-08-06 12:33:20 +00:00
self . to_entry . set_text ( to )
2005-07-01 15:15:35 +00:00
2005-11-30 22:22:22 +00:00
if gajim . config . get ( ' use_speller ' ) and HAS_GTK_SPELL :
try :
2005-12-12 09:12:29 +00:00
gtkspell . Spell ( self . conversation_textview )
2006-01-19 02:42:58 +00:00
gtkspell . Spell ( self . message_textview )
2005-11-30 22:22:22 +00:00
except gobject . GError , msg :
#FIXME: add a ui for this use spell.set_language()
2006-04-02 16:11:21 +00:00
ErrorDialog ( unicode ( msg ) , _ ( ' If that is not your language for which you want to highlight misspelled words, then please set your $LANG as appropriate. Eg. for French do export LANG=fr_FR or export LANG=fr_FR.UTF-8 in ~/.bash_profile or to make it global in /etc/profile. \n \n Highlighting misspelled words feature will not be used ' ) )
2005-11-30 22:22:22 +00:00
gajim . config . set ( ' use_speller ' , False )
2005-07-05 21:35:37 +00:00
self . send_button . set_no_show_all ( True )
self . reply_button . set_no_show_all ( True )
2005-07-05 23:55:33 +00:00
self . send_and_close_button . set_no_show_all ( True )
2005-07-05 21:35:37 +00:00
self . to_label . set_no_show_all ( True )
self . to_entry . set_no_show_all ( True )
self . from_label . set_no_show_all ( True )
self . from_entry . set_no_show_all ( True )
2005-12-08 14:51:35 +00:00
self . close_button . set_no_show_all ( True )
self . cancel_button . set_no_show_all ( True )
2005-12-12 09:12:29 +00:00
self . message_scrolledwindow . set_no_show_all ( True )
self . conversation_scrolledwindow . set_no_show_all ( True )
2005-07-05 21:35:37 +00:00
self . prepare_widgets_for ( self . action )
2005-07-26 15:23:11 +00:00
# set_text(None) raises TypeError exception
if self . subject is None :
self . subject = ' '
2005-07-05 21:35:37 +00:00
self . subject_entry . set_text ( self . subject )
self . xml . signal_autoconnect ( self )
2005-10-16 22:08:42 +00:00
if gajim . config . get ( ' saveposition ' ) :
# get window position and size from config
gtkgui_helpers . move_window ( self . window ,
2006-02-04 01:08:37 +00:00
gajim . config . get ( ' single-msg-x-position ' ) ,
gajim . config . get ( ' single-msg-y-position ' ) )
2005-10-16 22:08:42 +00:00
gtkgui_helpers . resize_window ( self . window ,
2006-02-04 01:08:37 +00:00
gajim . config . get ( ' single-msg-width ' ) ,
gajim . config . get ( ' single-msg-height ' ) )
2005-07-05 21:35:37 +00:00
self . window . show_all ( )
2005-11-17 23:04:56 +00:00
def set_cursor_to_end ( self ) :
end_iter = self . message_tv_buffer . get_end_iter ( )
self . message_tv_buffer . place_cursor ( end_iter )
2005-10-17 15:57:03 +00:00
def save_pos ( self ) :
2005-10-17 08:25:05 +00:00
if gajim . config . get ( ' saveposition ' ) :
# save the window size and position
x , y = self . window . get_position ( )
2006-02-04 01:08:37 +00:00
gajim . config . set ( ' single-msg-x-position ' , x )
gajim . config . set ( ' single-msg-y-position ' , y )
2005-10-17 08:25:05 +00:00
width , height = self . window . get_size ( )
2006-02-04 01:08:37 +00:00
gajim . config . set ( ' single-msg-width ' , width )
gajim . config . set ( ' single-msg-height ' , height )
gajim . interface . save_config ( )
2005-10-17 08:25:05 +00:00
2005-10-17 15:57:03 +00:00
def on_single_message_window_delete_event ( self , window , ev ) :
self . save_pos ( )
2005-07-05 21:35:37 +00:00
def prepare_widgets_for ( self , action ) :
2005-07-01 15:15:35 +00:00
if len ( gajim . connections ) > 1 :
2005-12-08 14:51:35 +00:00
#FIXME: for Received with should become 'in'
2005-11-28 16:29:04 +00:00
title = _ ( ' Single Message with account %s ' ) % self . account
2005-07-01 15:15:35 +00:00
else :
2005-07-05 21:35:37 +00:00
title = _ ( ' Single Message ' )
2005-12-08 14:51:35 +00:00
if action == ' send ' : # prepare UI for Sending
2005-07-05 21:35:37 +00:00
title = _ ( ' Send %s ' ) % title
self . send_button . show ( )
2005-07-05 23:55:33 +00:00
self . send_and_close_button . show ( )
2005-07-05 21:35:37 +00:00
self . to_label . show ( )
self . to_entry . show ( )
self . reply_button . hide ( )
self . from_label . hide ( )
self . from_entry . hide ( )
2005-12-12 09:12:29 +00:00
self . conversation_scrolledwindow . hide ( )
self . message_scrolledwindow . show ( )
2005-12-08 14:51:35 +00:00
if self . message : # we come from a reply?
self . message_textview . grab_focus ( )
self . cancel_button . hide ( )
self . close_button . show ( )
2005-12-12 09:12:29 +00:00
self . message_tv_buffer . set_text ( self . message )
gobject . idle_add ( self . set_cursor_to_end )
2005-12-08 14:51:35 +00:00
else : # we write a new message (not from reply)
self . close_button . hide ( )
if self . to : # do we already have jid?
self . subject_entry . grab_focus ( )
elif action == ' receive ' : # prepare UI for Receiving
2005-07-05 23:55:33 +00:00
title = _ ( ' Received %s ' ) % title
2005-07-05 21:35:37 +00:00
self . reply_button . show ( )
self . from_label . show ( )
self . from_entry . show ( )
self . send_button . hide ( )
2005-07-05 23:55:33 +00:00
self . send_and_close_button . hide ( )
2005-07-05 21:35:37 +00:00
self . to_label . hide ( )
self . to_entry . hide ( )
2005-12-12 09:12:29 +00:00
self . conversation_scrolledwindow . show ( )
self . message_scrolledwindow . hide ( )
if self . message :
self . conversation_textview . print_real_text ( self . message )
2005-12-08 14:51:35 +00:00
fjid = self . from_whom
if self . resource :
fjid + = ' / ' + self . resource # Full jid of sender (with resource)
self . from_entry . set_text ( fjid )
self . from_entry . set_property ( ' editable ' , False )
self . subject_entry . set_property ( ' editable ' , False )
self . reply_button . grab_focus ( )
self . cancel_button . hide ( )
self . close_button . show ( )
2005-07-02 15:49:25 +00:00
2005-07-05 21:35:37 +00:00
self . window . set_title ( title )
2005-07-01 15:15:35 +00:00
2005-07-02 15:49:25 +00:00
def on_cancel_button_clicked ( self , widget ) :
2005-10-17 15:57:03 +00:00
self . save_pos ( )
2005-07-02 15:49:25 +00:00
self . window . destroy ( )
2005-07-01 15:15:35 +00:00
2005-12-08 14:51:35 +00:00
def on_close_button_clicked ( self , widget ) :
self . save_pos ( )
self . window . destroy ( )
2005-07-02 15:49:25 +00:00
def update_char_counter ( self , widget ) :
characters_no = self . message_tv_buffer . get_char_count ( )
2005-08-26 00:52:44 +00:00
self . count_chars_label . set_text ( unicode ( characters_no ) )
2005-07-01 15:15:35 +00:00
2005-07-05 23:55:33 +00:00
def send_single_message ( self ) :
2005-08-06 19:14:21 +00:00
if gajim . connections [ self . account ] . connected < = 1 :
2005-12-08 14:51:35 +00:00
# if offline or connecting
2005-08-06 19:14:21 +00:00
ErrorDialog ( _ ( ' Connection not available ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' Please make sure you are connected with " %s " . ' % self . account ) )
2005-08-06 19:14:21 +00:00
return
2005-08-26 00:52:44 +00:00
to_whom_jid = self . to_entry . get_text ( ) . decode ( ' utf-8 ' )
subject = self . subject_entry . get_text ( ) . decode ( ' utf-8 ' )
2005-08-06 12:33:20 +00:00
begin , end = self . message_tv_buffer . get_bounds ( )
2005-08-26 00:52:44 +00:00
message = self . message_tv_buffer . get_text ( begin , end ) . decode ( ' utf-8 ' )
2005-08-06 12:33:20 +00:00
2005-08-07 11:40:48 +00:00
if to_whom_jid . find ( ' /announce/ ' ) != - 1 :
2005-08-06 12:33:20 +00:00
gajim . connections [ self . account ] . send_motd ( to_whom_jid , subject ,
message )
return
2005-08-06 19:14:21 +00:00
2005-07-02 15:49:25 +00:00
# FIXME: allow GPG message some day
gajim . connections [ self . account ] . send_message ( to_whom_jid , message ,
keyID = None , type = ' normal ' , subject = subject )
2005-07-05 21:57:19 +00:00
self . subject_entry . set_text ( ' ' ) # we sent ok, clear the subject
2005-07-02 15:49:25 +00:00
self . message_tv_buffer . set_text ( ' ' ) # we sent ok, clear the textview
2005-07-04 21:29:22 +00:00
2005-07-05 23:55:33 +00:00
def on_send_button_clicked ( self , widget ) :
self . send_single_message ( )
2005-07-05 21:35:37 +00:00
def on_reply_button_clicked ( self , widget ) :
# we create a new blank window to send and we preset RE: and to jid
self . subject = _ ( ' RE: %s ' ) % self . subject
2005-11-17 23:04:56 +00:00
self . message = _ ( ' %s wrote: \n ' % self . from_whom ) + self . message
# add > at the begining of each line
self . message = self . message . replace ( ' \n ' , ' \n > ' ) + ' \n \n '
2005-07-05 21:57:19 +00:00
self . window . destroy ( )
2005-10-20 11:17:17 +00:00
SingleMessageWindow ( self . account , to = self . from_whom ,
2005-07-05 21:35:37 +00:00
action = ' send ' , from_whom = self . from_whom , subject = self . subject ,
message = self . message )
2005-07-05 23:55:33 +00:00
def on_send_and_close_button_clicked ( self , widget ) :
self . send_single_message ( )
2005-10-17 15:57:03 +00:00
self . save_pos ( )
2005-07-05 23:55:33 +00:00
self . window . destroy ( )
def on_single_message_window_key_press_event ( self , widget , event ) :
if event . keyval == gtk . keysyms . Escape : # ESCAPE
2005-10-17 15:57:03 +00:00
self . save_pos ( )
2005-07-05 23:55:33 +00:00
self . window . destroy ( )
2005-07-04 21:29:22 +00:00
class XMLConsoleWindow :
2005-10-20 11:17:17 +00:00
def __init__ ( self , account ) :
2005-07-04 21:29:22 +00:00
self . account = account
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' xml_console_window ' , APP )
self . window = self . xml . get_widget ( ' xml_console_window ' )
self . input_textview = self . xml . get_widget ( ' input_textview ' )
self . stanzas_log_textview = self . xml . get_widget ( ' stanzas_log_textview ' )
2005-08-06 00:38:24 +00:00
self . input_tv_buffer = self . input_textview . get_buffer ( )
2005-08-05 23:43:28 +00:00
buffer = self . stanzas_log_textview . get_buffer ( )
2005-08-06 00:38:24 +00:00
end_iter = buffer . get_end_iter ( )
buffer . create_mark ( ' end ' , end_iter , False )
2005-08-05 23:43:28 +00:00
self . tagIn = buffer . create_tag ( ' incoming ' )
color = gajim . config . get ( ' inmsgcolor ' )
self . tagIn . set_property ( ' foreground ' , color )
self . tagOut = buffer . create_tag ( ' outgoing ' )
color = gajim . config . get ( ' outmsgcolor ' )
self . tagOut . set_property ( ' foreground ' , color )
2005-08-06 19:14:21 +00:00
self . enabled = False
2005-08-05 23:43:28 +00:00
2005-08-06 00:38:24 +00:00
self . input_textview . modify_text (
2005-08-05 23:43:28 +00:00
gtk . STATE_NORMAL , gtk . gdk . color_parse ( color ) )
2005-07-04 21:29:22 +00:00
if len ( gajim . connections ) > 1 :
2005-07-04 23:18:05 +00:00
title = _ ( ' XML Console for %s ' ) % self . account
2005-07-04 21:29:22 +00:00
else :
title = _ ( ' XML Console ' )
self . window . set_title ( title )
2006-04-05 12:01:21 +00:00
self . window . show_all ( )
2005-07-04 21:29:22 +00:00
self . xml . signal_autoconnect ( self )
2005-08-06 00:38:24 +00:00
def on_xml_console_window_delete_event ( self , widget , event ) :
self . window . hide ( )
return True # do NOT destroy the window
def on_clear_button_clicked ( self , widget ) :
2005-08-04 20:32:38 +00:00
buffer = self . stanzas_log_textview . get_buffer ( )
2005-08-06 00:38:24 +00:00
buffer . set_text ( ' ' )
def on_enable_checkbutton_toggled ( self , widget ) :
2005-08-06 19:14:21 +00:00
self . enabled = widget . get_active ( )
2005-08-06 00:38:24 +00:00
def scroll_to_end ( self , ) :
parent = self . stanzas_log_textview . get_parent ( )
buffer = self . stanzas_log_textview . get_buffer ( )
self . stanzas_log_textview . scroll_to_mark ( buffer . get_mark ( ' end ' ) , 0 , True ,
0 , 1 )
adjustment = parent . get_hadjustment ( )
adjustment . set_value ( 0 )
return False
def print_stanza ( self , stanza , kind ) :
# kind must be 'incoming' or 'outgoing'
2005-08-06 19:14:21 +00:00
if not self . enabled :
2005-08-06 00:38:24 +00:00
return
buffer = self . stanzas_log_textview . get_buffer ( )
at_the_end = False
end_iter = buffer . get_end_iter ( )
end_rect = self . stanzas_log_textview . get_iter_location ( end_iter )
visible_rect = self . stanzas_log_textview . get_visible_rect ( )
if end_rect . y < = ( visible_rect . y + visible_rect . height ) :
at_the_end = True
2005-08-04 20:32:38 +00:00
end_iter = buffer . get_end_iter ( )
2005-11-14 10:14:55 +00:00
buffer . insert_with_tags_by_name ( end_iter , stanza . replace ( ' >< ' , ' > \n < ' ) + \
' \n \n ' , kind )
2005-08-06 00:38:24 +00:00
if at_the_end :
gobject . idle_add ( self . scroll_to_end )
2005-08-04 20:32:38 +00:00
2005-07-04 21:29:22 +00:00
def on_send_button_clicked ( self , widget ) :
2005-08-06 19:14:21 +00:00
if gajim . connections [ self . account ] . connected < = 1 :
#if offline or connecting
ErrorDialog ( _ ( ' Connection not available ' ) ,
2006-04-02 16:11:21 +00:00
_ ( ' Please make sure you are connected with " %s " . ' % self . account ) )
2005-08-06 19:14:21 +00:00
return
2005-07-04 21:29:22 +00:00
begin_iter , end_iter = self . input_tv_buffer . get_bounds ( )
2005-08-26 00:52:44 +00:00
stanza = self . input_tv_buffer . get_text ( begin_iter , end_iter ) . decode ( ' utf-8 ' )
2005-07-04 21:29:22 +00:00
if stanza :
gajim . connections [ self . account ] . send_stanza ( stanza )
self . input_tv_buffer . set_text ( ' ' ) # we sent ok, clear the textview
def on_presence_button_clicked ( self , widget ) :
self . input_tv_buffer . set_text (
' <presence><show></show><status></status><priority></priority></presence> '
)
def on_iq_button_clicked ( self , widget ) :
self . input_tv_buffer . set_text (
' <iq to= " " type= " " ><query xmlns= " " ></query></iq> '
)
def on_message_button_clicked ( self , widget ) :
self . input_tv_buffer . set_text (
' <message to= " " type= " " ><body></body></message> '
)
2005-07-04 23:18:05 +00:00
def on_expander_activate ( self , widget ) :
if not widget . get_expanded ( ) : # it's the opposite!
# it's expanded!!
self . input_textview . grab_focus ( )
2005-08-14 23:21:57 +00:00
2005-09-11 15:02:22 +00:00
class InvitationReceivedDialog :
2005-10-20 11:17:17 +00:00
def __init__ ( self , account , room_jid , contact_jid , password = None , comment = None ) :
2006-04-02 16:11:21 +00:00
self . room_jid = room_jid
self . account = account
2005-09-11 15:02:22 +00:00
xml = gtk . glade . XML ( GTKGUI_GLADE , ' invitation_received_dialog ' , APP )
2006-04-02 16:11:21 +00:00
self . dialog = xml . get_widget ( ' invitation_received_dialog ' )
2005-09-11 15:02:22 +00:00
2006-03-10 13:43:20 +00:00
#FIXME: use nickname instead of contact_jid
pritext = _ ( ' %(contact_jid)s has invited you to %(room_jid)s room ' ) % {
2006-03-10 13:17:21 +00:00
' room_jid ' : room_jid , ' contact_jid ' : contact_jid }
2006-03-10 13:43:20 +00:00
label_text = ' <big><b> %s </b></big> ' % pritext
2006-03-10 14:01:57 +00:00
if comment : # only if not None and not ''
2005-09-11 15:02:22 +00:00
sectext = _ ( ' Comment: %s ' ) % comment
2006-03-10 13:43:20 +00:00
label_text + = ' \n \n %s ' % sectext
2005-09-09 19:42:47 +00:00
2006-03-10 13:43:20 +00:00
xml . get_widget ( ' label ' ) . set_markup ( label_text )
2006-04-02 16:11:21 +00:00
xml . get_widget ( ' deny_button ' ) . connect ( ' clicked ' ,
self . on_deny_button_clicked )
xml . get_widget ( ' accept_button ' ) . connect ( ' clicked ' ,
self . on_accept_button_clicked )
self . dialog . show_all ( )
def on_deny_button_clicked ( self , widget ) :
self . dialog . destroy ( )
def on_accept_button_clicked ( self , widget ) :
self . dialog . destroy ( )
room , server = gajim . get_room_name_and_server_from_room_jid ( self . room_jid )
JoinGroupchatWindow ( self . account , server = server , room = room )
2005-09-11 15:02:22 +00:00
2005-12-02 16:18:04 +00:00
class ProgressDialog :
2005-12-02 17:16:23 +00:00
def __init__ ( self , title_text , during_text , messages_queue ) :
2005-12-02 16:18:04 +00:00
''' during text is what to show during the procedure,
messages_queue has the message to show
in the textview '''
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' progress_dialog ' , APP )
2005-12-05 11:13:08 +00:00
self . dialog = self . xml . get_widget ( ' progress_dialog ' )
2005-12-02 17:16:23 +00:00
self . label = self . xml . get_widget ( ' label ' )
2005-12-02 16:18:04 +00:00
self . label . set_markup ( ' <big> ' + during_text + ' </big> ' )
2005-12-02 17:16:23 +00:00
self . progressbar = self . xml . get_widget ( ' progressbar ' )
2005-12-05 11:13:08 +00:00
self . dialog . set_title ( title_text )
2006-04-07 22:57:27 +00:00
self . dialog . set_default_size ( 450 , 250 )
2005-12-05 11:13:08 +00:00
self . dialog . show_all ( )
2005-12-02 17:16:23 +00:00
self . xml . signal_autoconnect ( self )
2005-12-02 16:18:04 +00:00
self . update_progressbar_timeout_id = gobject . timeout_add ( 100 ,
self . update_progressbar )
2006-04-07 22:57:27 +00:00
2005-12-02 16:18:04 +00:00
def update_progressbar ( self ) :
2006-04-07 22:57:27 +00:00
if self . dialog :
self . progressbar . pulse ( )
return True # loop forever
return False
2005-12-02 16:18:04 +00:00
def on_progress_dialog_delete_event ( self , widget , event ) :
return True # WM's X button or Escape key should not destroy the window
2006-03-15 17:45:55 +00:00
class SoundChooserDialog :
def __init__ ( self , path_to_snd_file = ' ' ) :
''' optionally accepts path_to_snd_file so it has that as selected '''
self . dialog = gtk . FileChooserDialog ( _ ( ' Choose Sound ' ) , None ,
gtk . FILE_CHOOSER_ACTION_OPEN ,
( gtk . STOCK_CANCEL , gtk . RESPONSE_CANCEL ,
gtk . STOCK_OPEN , gtk . RESPONSE_OK ) )
self . dialog . set_default_response ( gtk . RESPONSE_OK )
last_sounds_dir = gajim . config . get ( ' last_sounds_dir ' )
if last_sounds_dir and os . path . isdir ( ' last_sounds_dir ' ) :
self . dialog . set_current_folder ( last_sounds_dir )
else :
self . dialog . set_current_folder ( gajim . HOME_DIR )
filter = gtk . FileFilter ( )
filter . set_name ( _ ( ' All files ' ) )
filter . add_pattern ( ' * ' )
self . dialog . add_filter ( filter )
filter = gtk . FileFilter ( )
filter . set_name ( _ ( ' Wav Sounds ' ) )
filter . add_pattern ( ' *.wav ' )
self . dialog . add_filter ( filter )
self . dialog . set_filter ( filter )
self . path_to_snd_file = path_to_snd_file
self . dialog . set_filename ( self . path_to_snd_file )
self . path_to_snd_file = ' '
while True :
response = self . dialog . run ( )
if response != gtk . RESPONSE_OK :
break
self . path_to_snd_file = self . dialog . get_filename ( )
try :
self . path_to_snd_file = path_to_snd_file . decode (
sys . getfilesystemencoding ( ) )
except :
pass
if os . path . exists ( self . path_to_snd_file ) :
break
class AddSpecialNotificationDialog :
def __init__ ( self , jid ) :
''' jid is the jid for which we want to add special notification
( sound and notification popups ) '''
self . xml = gtk . glade . XML ( GTKGUI_GLADE , ' add_special_notification_window ' ,
APP )
self . window = self . xml . get_widget ( ' add_special_notification_window ' )
self . condition_combobox = self . xml . get_widget ( ' condition_combobox ' )
self . condition_combobox . set_active ( 0 )
self . notification_popup_yes_no_combobox = self . xml . get_widget (
' notification_popup_yes_no_combobox ' )
self . notification_popup_yes_no_combobox . set_active ( 0 )
self . listen_sound_combobox = self . xml . get_widget ( ' listen_sound_combobox ' )
self . listen_sound_combobox . set_active ( 0 )
self . jid = jid
self . xml . get_widget ( ' when_foo_becomes_label ' ) . set_text (
_ ( ' When %s becomes: ' ) % self . jid )
self . window . set_title ( _ ( ' Adding Special Notification for %s ' ) % jid )
self . window . show_all ( )
self . xml . signal_autoconnect ( self )
def on_cancel_button_clicked ( self , widget ) :
self . window . destroy ( )
def on_add_special_notification_window_delete_event ( self , widget , event ) :
self . window . destroy ( )
def on_listen_sound_combobox_changed ( self , widget ) :
model = widget . get_model ( )
active = widget . get_active ( )
if active == 1 : # user selected 'choose sound'
dlg_instance = SoundChooserDialog ( )
path_to_snd_file = dlg_instance . path_to_snd_file
dlg_instance . dialog . destroy ( )
if path_to_snd_file :
print path_to_snd_file
else : # user selected nothing (X button or Cancel)
widget . set_active ( 0 ) # go back to No Sound
#model[iter][0] =
def on_ok_button_clicked ( self , widget ) :
conditions = ( ' online ' , ' chat ' , ' online_and_chat ' ,
' away ' , ' xa ' , ' away_and_xa ' , ' dnd ' , ' xa_and_dnd ' , ' offline ' )
active = self . condition_combobox . get_active ( )
print conditions [ active ]
active_iter = self . listen_sound_combobox . get_active_iter ( )
listen_sound_model = self . listen_sound_combobox . get_model ( )
print listen_sound_model [ active_iter ] [ 0 ]