Ticket #1742: untested_patch.diff

File untested_patch.diff, 4.2 kB (added by nk, 2 years ago)

in theory it all works nicely. I could be wrong in a place or two (especially on the params on the table.attach method). This should have been in from GTK 0.1 not GTK 2.10 but anywayzzzzzz

  • src/vcard.py

     
    231231                        menu.popup(None, None, None, event.button, event.time) 
    232232 
    233233        def set_value(self, entry_name, value): 
     234                '''puts the value in the entry_name label''' 
    234235                try: 
    235236                        self.xml.get_widget(entry_name).set_text(value) 
    236237                except AttributeError: 
    237238                        pass 
    238239 
    239240        def set_values(self, vcard): 
    240                 for i in vcard.keys(): 
    241                         if i == 'PHOTO': 
     241                '''puts the info from the vcard dict to the window''' 
     242                for key in vcard.keys(): 
     243                        if key == 'PHOTO': 
    242244                                pixbuf, self.avatar_encoded, self.avatar_mime_type = \ 
    243                                         get_avatar_pixbuf_encoded_mime(vcard[i]) 
     245                                        get_avatar_pixbuf_encoded_mime(vcard[key]) 
    244246                                if not pixbuf: 
    245247                                        continue 
    246248                                image = self.xml.get_widget('PHOTO_image') 
     
    250252                                self.avatar_save_as_id = eventbox.connect('button-press-event', 
    251253                                        self.on_PHOTO_eventbox_button_press_event) 
    252254                                continue 
    253                         if i == 'ADR' or i == 'TEL' or i == 'EMAIL': 
    254                                 for entry in vcard[i]: 
     255                        if key in ('ADR', 'TEL', 'EMAIL'): 
     256                                for entry in vcard[key]: 
    255257                                        add_on = '_HOME' 
    256258                                        if 'WORK' in entry: 
    257259                                                add_on = '_WORK' 
    258260                                        for j in entry.keys(): 
    259                                                 self.set_value(i + add_on + '_' + j + '_entry', entry[j]) 
    260                         if isinstance(vcard[i], dict): 
    261                                 for j in vcard[i].keys(): 
    262                                         self.set_value(i + '_' + j + '_entry', vcard[i][j]) 
     261                                                self.set_value(key + add_on + '_' + j + '_entry', entry[j]) 
     262                        if isinstance(vcard[key], dict): 
     263                                for j in vcard[key].keys(): 
     264                                        self.set_value(key + '_' + j + '_entry', vcard[key][j]) 
    263265                        else: 
    264                                 if i == 'DESC': 
     266                                if key == 'DESC': 
    265267                                        self.xml.get_widget('DESC_textview').get_buffer().set_text( 
    266                                                 vcard[i], 0) 
     268                                                vcard[key], 0) 
     269                                elif gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0) and key == 'URL': 
     270                                        #FIXME: remove all this stuff when we migrate to GTK 2.10 
     271                                        general_info_table = self.xml.get_widget('general_info_table') 
     272                                        general_info_table.remove(self.xml.get_widget('URL_entry')) 
     273                                        general_info_table.attach(gtk.LinkButton(key, key), 0, 1, 5, 6) 
     274                                                 
    267275                                else: 
    268                                         self.set_value(i + '_entry', vcard[i]) 
     276                                        self.set_value(key + '_entry', vcard[key]) 
    269277 
    270278        def set_last_status_time(self): 
    271279                self.fill_status_label() 
     
    436444                        'ORG_ORGUNIT', 'TITLE', 'ROLE', 'TEL_WORK_NUMBER', 'EMAIL_WORK_USERID', 
    437445                        'ADR_WORK_STREET', 'ADR_WORK_EXTADR', 'ADR_WORK_LOCALITY', 
    438446                        'ADR_WORK_REGION', 'ADR_WORK_PCODE', 'ADR_WORK_CTRY'] 
     447                         
    439448                vcard = {} 
    440                 for e in entries:  
    441                         txt = self.xml.get_widget(e + '_entry').get_text().decode('utf-8') 
     449                for entry in entries:  
     450                        txt = self.xml.get_widget(entry + '_entry').get_text()\ 
     451                                .decode('utf-8') 
    442452                        if txt != '': 
    443                                 vcard = self.add_to_vcard(vcard, e, txt) 
     453                                vcard = self.add_to_vcard(vcard, entry, txt) 
    444454 
    445455                # DESC textview 
    446456                buff = self.xml.get_widget('DESC_textview').get_buffer() 
     
    480490                        'ORG_ORGUNIT', 'TITLE', 'ROLE', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR', 
    481491                        'ADR_WORK_LOCALITY', 'ADR_WORK_REGION', 'ADR_WORK_PCODE', 
    482492                        'ADR_WORK_CTRY'] 
     493                 
     494                if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0): 
     495                        entries.remove('URL') 
     496                        #FIXME: when we migrate to 2.10 remove URL from entries list completely 
     497                         
    483498                if gajim.connections[self.account].connected > 1: 
    484499                        # clear all entries 
    485500                        for e in entries: 
  • data/glade/vcard_information_window.glade

     
    621621          </child> 
    622622 
    623623          <child> 
    624             <widget class="GtkTable" id="table11"> 
     624            <widget class="GtkTable" id="general_info_table"> 
    625625              <property name="border_width">6</property> 
    626626              <property name="visible">True</property> 
    627627              <property name="n_rows">7</property> 
     
    708708              </child> 
    709709 
    710710              <child> 
    711                 <widget class="GtkLabel" id="label119"> 
     711                <widget class="GtkLabel" id="URL_label"> 
    712712                  <property name="visible">True</property> 
    713713                  <property name="label" translatable="yes">Homepage:</property> 
    714714                  <property name="use_underline">False</property>