Changeset 7841 for branches/gajim_0.11/src
- Timestamp:
- 01/15/07 19:51:27 (19 months ago)
- Location:
- branches/gajim_0.11/src
- Files:
-
- 8 modified
-
advanced.py (modified) (5 diffs)
-
common/commands.py (modified) (14 diffs)
-
common/config.py (modified) (1 diff)
-
config.py (modified) (5 diffs)
-
conversation_textview.py (modified) (2 diffs)
-
dialogs.py (modified) (44 diffs)
-
message_window.py (modified) (1 diff)
-
roster_window.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gajim_0.11/src/advanced.py
r7095 r7841 47 47 # value = array(oldval, newval) 48 48 self.changed_opts = {} 49 50 # For i18n 51 self.right_true_dict = {True: _('Activated'), False: _('Deactivated')} 52 self.types = { 53 'boolean': _('Boolean'), 54 'integer': _('Integer'), 55 'string': _('Text'), 56 'color': _('Color')} 49 57 50 58 treeview = self.xml.get_widget('advanced_treeview') … … 92 100 optname = model[iter][C_PREFNAME] 93 101 opttype = model[iter][C_TYPE] 94 if opttype == 'boolean' or optname in ('password', 'gpgpassword'): 102 if opttype == self.types['boolean'] or optname in ('password', 103 'gpgpassword'): 95 104 cell.set_property('editable', False) 96 105 else: … … 138 147 modelrow = self.model[modelpath] 139 148 option = modelrow[0].decode('utf-8') 140 if modelrow[2] == 'boolean': 141 newval = {'False': 'True', 'True': 'False'}[modelrow[1]] 149 if modelrow[2] == self.types['boolean']: 150 for key in self.right_true_dict.keys(): 151 if self.right_true_dict[key] == modelrow[1]: 152 modelrow[1] = key 153 newval = {'False': True, 'True': False}[modelrow[1]] 142 154 if len(modelpath) > 1: 143 155 optnamerow = self.model[modelpath[0]] … … 153 165 gajim.config.set(option, newval) 154 166 gajim.interface.save_config() 155 modelrow[1] = newval167 modelrow[1] = self.right_true_dict[newval] 156 168 self.check_for_restart() 157 169 … … 222 234 if val[OPT_TYPE]: 223 235 type = val[OPT_TYPE][0] 236 type = self.types[type] # i18n 224 237 value = val[OPT_VAL] 225 238 if name in ('password', 'gpgpassword'): 226 239 #we talk about password 227 240 value = _('Hidden') # override passwords with this string 241 if value in self.right_true_dict: 242 value = self.right_true_dict[value] 228 243 model.append(iter, [name, value, type]) 229 244 -
branches/gajim_0.11/src/common/commands.py
r7829 r7841 26 26 ''' This returns True if that command should be visible and invokable 27 27 for others. 28 samejid - True when command is invoked by an entity with the same bare jid.29 '''28 samejid - True when command is invoked by an entity with the same bare 29 jid.''' 30 30 return True 31 31 … … 35 35 self.sessionid = sessionid 36 36 37 def buildResponse(self, request, status='executing', defaultaction=None, actions=None): 37 def buildResponse(self, request, status = 'executing', defaultaction = None, 38 actions = None): 38 39 assert status in ('executing', 'completed', 'canceled') 39 40 … … 46 47 if defaultaction is not None or actions is not None: 47 48 if defaultaction is not None: 48 assert defaultaction in ('cancel', 'execute', 'prev', 'next', 'complete') 49 assert defaultaction in ('cancel', 'execute', 'prev', 'next', 50 'complete') 49 51 attrs = {'action': defaultaction} 50 52 else: … … 55 57 56 58 def badRequest(self, stanza): 57 self.connection.connection.send(xmpp.Error(stanza, xmpp.NS_STANZAS+' bad-request')) 59 self.connection.connection.send(xmpp.Error(stanza, xmpp.NS_STANZAS + \ 60 ' bad-request')) 58 61 59 62 def cancel(self, request): 60 response, cmd = self.buildResponse(request, status ='canceled')63 response, cmd = self.buildResponse(request, status = 'canceled') 61 64 self.connection.connection.send(response) 62 65 return False # finish the session … … 64 67 class ChangeStatusCommand(AdHocCommand): 65 68 commandnode = 'change-status' 66 commandname = 'Change status information'69 commandname = _('Change status information') 67 70 68 71 @staticmethod … … 73 76 def execute(self, request): 74 77 # first query... 75 response, cmd = self.buildResponse(request, defaultaction='execute', actions=['execute']) 78 response, cmd = self.buildResponse(request, defaultaction = 'execute', 79 actions = ['execute']) 76 80 77 cmd.addChild(node =dataforms.SimpleDataForm(78 title ='Change status',79 instructions ='Set the presence type and description',80 fields =[81 cmd.addChild(node = dataforms.SimpleDataForm( 82 title = _('Change status'), 83 instructions = _('Set the presence type and description'), 84 fields = [ 81 85 dataforms.Field('list-single', 82 var ='presence-type',83 label ='Type of presence:',84 options =[85 (u'free-for-chat', u'Free for chat'),86 (u'online', u'Online'),87 (u'away', u'Away'),88 (u'xa', u'Extended away'),89 (u'dnd', u'Do not disturb'),90 (u'offline', u'Offline - disconnect')],91 value ='online',92 required =True),86 var = 'presence-type', 87 label = 'Type of presence:', 88 options = [ 89 (u'free-for-chat', _('Free for chat')), 90 (u'online', _('Online')), 91 (u'away', _('Away')), 92 (u'xa', _('Extended away')), 93 (u'dnd', _('Do not disturb')), 94 (u'offline', _('Offline - disconnect'))], 95 value = 'online', 96 required = True), 93 97 dataforms.Field('text-multi', 94 var ='presence-desc',95 label ='Presence description:')]))98 var = 'presence-desc', 99 label = _('Presence description:'))])) 96 100 97 101 self.connection.connection.send(response) … … 105 109 # check if the data is correct 106 110 try: 107 form=dataforms.SimpleDataForm(extend=request.getTag('command').getTag('x')) 111 form = dataforms.SimpleDataForm(extend = request.getTag('command').\ 112 getTag('x')) 108 113 except: 109 114 self.badRequest(request) 110 115 return False 111 116 112 117 try: 113 118 presencetype = form['presence-type'].value … … 126 131 presencedesc = u'' 127 132 128 response, cmd = self.buildResponse(request, status ='completed')129 cmd.addChild('note', {}, 'The status has been changed.')133 response, cmd = self.buildResponse(request, status = 'completed') 134 cmd.addChild('note', {}, _('The status has been changed.')) 130 135 131 136 # if going offline, we need to push response so it won't go into 132 137 # queue and disappear 133 self.connection.connection.send(response, presencetype =='offline')138 self.connection.connection.send(response, presencetype == 'offline') 134 139 135 140 # send new status 136 gajim.interface.roster.send_status(self.connection.name, presencetype, presencedesc) 141 gajim.interface.roster.send_status(self.connection.name, presencetype, 142 presencedesc) 137 143 138 144 return False # finish the session 145 146 def find_current_groupchats(account): 147 import message_control 148 rooms = [] 149 for gc_control in gajim.interface.msg_win_mgr.get_controls( 150 message_control.TYPE_GC): 151 acct = gc_control.account 152 # check if account is the good one 153 if acct != account: 154 continue 155 room_jid = gc_control.room_jid 156 nick = gc_control.nick 157 if gajim.gc_connected[acct].has_key(room_jid) and \ 158 gajim.gc_connected[acct][room_jid]: 159 rooms.append((room_jid, nick,)) 160 return rooms 161 162 163 class LeaveGroupchatsCommand(AdHocCommand): 164 commandnode = 'leave-groupchats' 165 commandname = 'Leave Groupchats' 166 167 @staticmethod 168 def isVisibleFor(samejid): 169 ''' Change status is visible only if the entity has the same bare jid. ''' 170 return samejid 171 172 def execute(self, request): 173 # first query... 174 response, cmd = self.buildResponse(request, defaultaction = 'execute', 175 actions=['execute']) 176 options = [] 177 account = self.connection.name 178 for gc in find_current_groupchats(account): 179 options.append((u'%s' %(gc[0]), _('%(nickname)s on %(room_jid)s') % \ 180 {'nickname': gc[1], 'room_jid': gc[0]})) 181 if not len(options): 182 response, cmd = self.buildResponse(request, status = 'completed') 183 cmd.addChild('note', {}, _('You have not joined a groupchat.')) 184 185 self.connection.connection.send(response) 186 return False 187 188 cmd.addChild(node=dataforms.SimpleDataForm( 189 title = _('Leave Groupchats'), 190 instructions = _('Choose the groupchats you want to leave'), 191 fields=[ 192 dataforms.Field('list-multi', 193 var = 'groupchats', 194 label = _('Groupchats'), 195 options = options, 196 required = True)])) 197 198 self.connection.connection.send(response) 199 200 # for next invocation 201 self.execute = self.leavegroupchats 202 203 return True # keep the session 204 205 def leavegroupchats(self, request): 206 # check if the data is correct 207 try: 208 form = dataforms.SimpleDataForm(extend = request.getTag('command').\ 209 getTag('x')) 210 except: 211 self.badRequest(request) 212 return False 213 214 try: 215 gc = form['groupchats'].values 216 except: # KeyError if there's no presence-type field in form or 217 # AttributeError if that field is of wrong type 218 self.badRequest(request) 219 return False 220 account = self.connection.name 221 try: 222 for room_jid in gc: 223 gc_control = gajim.interface.msg_win_mgr.get_control(room_jid, 224 account) 225 gc_control.parent_win.remove_tab(gc_control, None, force = True) 226 except: # KeyError if there's no presence-type field in form or 227 self.badRequest(request) 228 return False 229 response, cmd = self.buildResponse(request, status = 'completed') 230 note = _('You leaved the following groupchats:') 231 for room_jid in gc: 232 note += '\n\t' + room_jid 233 cmd.addChild('note', {}, note) 234 235 self.connection.connection.send(response) 236 return False 237 139 238 140 239 class ConnectionCommands: … … 143 242 # a list of all commands exposed: node -> command class 144 243 self.__commands = {} 145 for cmdobj in (ChangeStatusCommand, ):244 for cmdobj in (ChangeStatusCommand, LeaveGroupchatsCommand): 146 245 self.__commands[cmdobj.commandnode] = cmdobj 147 246 … … 165 264 q.addChild('item', { 166 265 # TODO: find the jid 167 'jid': self.getOurBareJID() +u'/'+self.server_resource,266 'jid': self.getOurBareJID() + u'/' + self.server_resource, 168 267 'node': node, 169 268 'name': cmd.commandname}) … … 210 309 if node not in self.__commands.keys(): 211 310 self.connection.send( 212 xmpp.Error(iq_obj, xmpp.NS_STANZAS +' item-not-found'))311 xmpp.Error(iq_obj, xmpp.NS_STANZAS + ' item-not-found')) 213 312 raise xmpp.NodeProcessed 214 313 … … 221 320 222 321 # create new instance and run it 223 obj = newcmd(conn =self, jid=jid, sessionid=sessionid)322 obj = newcmd(conn = self, jid = jid, sessionid = sessionid) 224 323 rc = obj.execute(iq_obj) 225 324 if rc: … … 237 336 238 337 try: 239 if action == 'cancel': rc = obj.cancel(iq_obj) 240 elif action == 'prev': rc = obj.prev(iq_obj) 241 elif action == 'next': rc = obj.next(iq_obj) 338 if action == 'cancel': 339 rc = obj.cancel(iq_obj) 340 elif action == 'prev': 341 rc = obj.prev(iq_obj) 342 elif action == 'next': 343 rc = obj.next(iq_obj) 242 344 elif action == 'execute' or action is None: 243 rc = obj.execute(iq_obj) 244 elif action == 'complete': rc = obj.complete(iq_obj) 345 rc = obj.execute(iq_obj) 346 elif action == 'complete': 347 rc = obj.complete(iq_obj) 245 348 else: 246 349 # action is wrong. stop the session, send error … … 257 360 258 361 raise xmpp.NodeProcessed 259 -
branches/gajim_0.11/src/common/config.py
r7829 r7841 131 131 'latest_disco_addresses': [ opt_str, '' ], 132 132 'recently_groupchat': [ opt_str, '' ], 133 ' before_nickname': [ opt_str, ''],134 ' time_stamp': [ opt_str, '[%H:%M] '],135 'after_nickname': [ opt_str, ':' ],133 'time_stamp': [ opt_str, '[%X] ', _('This option let you customize timestamp that is printed in conversation. For exemple "[%H:%M] " will show "[hour:minute] ". See python doc on strftime for full documentation: http://docs.python.org/lib/module-time.html') ], 134 'before_nickname': [ opt_str, '', _('Characters that are printed before the nickname in conversations') ], 135 'after_nickname': [ opt_str, ':', _('Characters that are printed after the nickname in conversations') ], 136 136 'send_os_info': [ opt_bool, True ], 137 137 'set_status_msg_from_current_music_track': [ opt_bool, False ], -
branches/gajim_0.11/src/config.py
r7829 r7841 93 93 w.hide() 94 94 95 # trayicon95 # trayicon 96 96 if gajim.interface.systray_capabilities: 97 97 st = gajim.config.get('trayicon') … … 100 100 self.trayicon_checkbutton.set_sensitive(False) 101 101 102 # Save position102 # Save position 103 103 st = gajim.config.get('saveposition') 104 104 self.xml.get_widget('save_position_checkbutton').set_active(st) … … 241 241 self.xml.get_widget('time_always_radiobutton').set_active(True) 242 242 243 # TimeStamp244 st = gajim.config.get('time_stamp')245 st = helpers.from_one_line(st)246 self.xml.get_widget('time_stamp_textview').get_buffer().set_text(st)247 248 # before nickname249 st = gajim.config.get('before_nickname')250 st = helpers.from_one_line(st)251 self.xml.get_widget('before_nickname_textview').get_buffer().set_text(st)252 253 # after nickanme254 st = gajim.config.get('after_nickname')255 st = helpers.from_one_line(st)256 self.xml.get_widget('after_nickname_textview').get_buffer().set_text(st)257 258 243 # Color for incoming messages 259 244 colSt = gajim.config.get('inmsgcolor') … … 732 717 gajim.config.set('print_time', 'always') 733 718 self._set_sensitivity_for_before_after_time_widgets(True) 734 gajim.interface.save_config()735 736 def _get_textview_text(self, tv):737 buffer = tv.get_buffer()738 begin, end = buffer.get_bounds()739 return buffer.get_text(begin, end).decode('utf-8')740 741 def on_time_stamp_textview_focus_out_event(self, widget, event):742 text = self._get_textview_text(widget)743 text = helpers.to_one_line(text)744 gajim.config.set('time_stamp', text)745 gajim.interface.save_config()746 747 def on_before_nickname_textview_focus_out_event(self, widget, event):748 text = self._get_textview_text(widget)749 text = helpers.to_one_line(text)750 gajim.config.set('before_nickname', text)751 gajim.interface.save_config()752 753 def on_after_nickname_textview_focus_out_event(self, widget, event):754 text = self._get_textview_text(widget)755 text = helpers.to_one_line(text)756 gajim.config.set('after_nickname', text)757 719 gajim.interface.save_config() 758 720 … … 2660 2622 self.option_list = {'': _('Default'), 'all': Q_('?print_status:All'), 2661 2623 'in_and_out': _('Enter and leave only'), 2662 'none': _('?print_status:None')}2624 'none': Q_('?print_status:None')} 2663 2625 opts = self.option_list.keys() 2664 2626 opts.sort() -
branches/gajim_0.11/src/conversation_textview.py
r7829 r7841 689 689 current_print_time = gajim.config.get('print_time') 690 690 if current_print_time == 'always' and kind != 'info': 691 timestamp_str = gajim.config.get('time_stamp') 692 timestamp_str = helpers.from_one_line(timestamp_str) 691 timestamp_str = self.get_time_to_show(tim) 693 692 timestamp = time.strftime(timestamp_str, tim) 694 693 buffer.insert_with_tags_by_name(end_iter, timestamp, … … 758 757 if day_str: 759 758 format += day_str + ' ' 760 format += '%X' 759 timestamp_str = gajim.config.get('time_stamp') 760 timestamp_str = helpers.from_one_line(timestamp_str) 761 format += timestamp_str 761 762 tim_format = time.strftime(format, tim) 762 763 if locale.getpreferredencoding() != 'KOI8-R': -
branches/gajim_0.11/src/dialogs.py
r7829 r7841 215 215 column.pack_start(renderer) 216 216 column.set_attributes(renderer, text = 0) 217 217 218 218 column = gtk.TreeViewColumn(_('In the group')) 219 219 column.set_expand(False) … … 320 320 title_text = _('Status Message') 321 321 self.window.set_title(title_text) 322 322 323 323 message_textview = self.xml.get_widget('message_textview') 324 324 self.message_buffer = message_textview.get_buffer() … … 332 332 msg = helpers.from_one_line(msg) 333 333 self.message_buffer.set_text(msg) 334 334 335 335 # have an empty string selectable, so user can clear msg 336 336 self.preset_messages_dict = {'': ''} … … 340 340 self.preset_messages_dict[msg_name] = msg_text 341 341 sorted_keys_list = helpers.get_sorted_keys(self.preset_messages_dict) 342 342 343 343 self.message_liststore = gtk.ListStore(str) # msg_name 344 344 self.message_combobox = self.xml.get_widget('message_combobox') … … 375 375 name = model[active][0].decode('utf-8') 376 376 self.message_buffer.set_text(self.preset_messages_dict[name]) 377 377 378 378 def on_change_status_message_dialog_key_press_event(self, widget, event): 379 379 if event.keyval == gtk.keysyms.Return or \ … … 388 388 else: 389 389 btn.set_sensitive(True) 390 390 391 391 def on_save_as_preset_button_clicked(self, widget): 392 392 start_iter, finish_iter = self.message_buffer.get_bounds() … … 404 404 msg_name = msg_name.decode('utf-8') 405 405 iter_ = self.message_liststore.append((msg_name,)) 406 406 407 407 gajim.config.add_per('statusmsg', msg_name) 408 408 gajim.config.set_per('statusmsg', msg_name, 'message', msg_text_1l) … … 602 602 'utf-8') 603 603 jid = jid.replace('@', '%') + '@' + transport 604 604 605 605 # check if jid is conform to RFC and stringprep it 606 606 try: … … 727 727 text = open(copying_file_path).read() 728 728 dlg.set_license(text) 729 729 730 730 dlg.set_comments('%s\n%s %s\n%s %s' 731 731 % (_('A GTK+ jabber client'), \ … … <
