Ticket #1982: gmail_extra_details-v1.patch

File gmail_extra_details-v1.patch, 5.8 kB (added by bluegray, 3 years ago)
  • src/config.py

     
    441441                # Notify user of new gmail e-mail messages, 
    442442                # only show checkbox if user has a gtalk account 
    443443                notify_gmail_checkbutton = self.xml.get_widget('notify_gmail_checkbutton') 
     444                notify_gmail_extra_checkbutton = self.xml.get_widget('notify_gmail_extra_checkbutton') 
    444445                notify_gmail_checkbutton.set_no_show_all(True) 
     446                notify_gmail_extra_checkbutton.set_no_show_all(True) 
    445447                for account in gajim.config.get_per('accounts'): 
    446448                        jid = gajim.get_jid_from_account(account) 
    447449                        if gajim.get_server_from_jid(jid) == 'gmail.com': 
    448450                                st = gajim.config.get('notify_on_new_gmail_email') 
    449451                                notify_gmail_checkbutton.set_active(st) 
    450452                                notify_gmail_checkbutton.show() 
     453                                st = gajim.config.get('notify_on_new_gmail_email_extra') 
     454                                notify_gmail_extra_checkbutton.set_active(st) 
     455                                notify_gmail_extra_checkbutton.show() 
    451456                                break 
    452457                else: 
    453458                        notify_gmail_checkbutton.hide() 
     459                        notify_gmail_extra_checkbutton.hide() 
    454460                 
    455461                self.xml.signal_autoconnect(self) 
    456462 
     
    846852        def on_send_os_info_checkbutton_toggled(self, widget): 
    847853                self.on_checkbutton_toggled(widget, 'send_os_info') 
    848854                 
    849         def on_notify_gmail_checkbutton_toggled(self, widget):  
     855        def on_notify_gmail_checkbutton_toggled(self, widget): 
    850856                self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email') 
     857 
     858        def on_notify_gmail_extra_checkbutton_toggled(self, widget): 
     859                self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email_extra') 
    851860                 
    852861        def fill_msg_treeview(self): 
    853862                self.xml.get_widget('delete_msg_button').set_sensitive(False) 
  • src/gajim.py

     
    10261026        def handle_event_gmail_notify(self, account, array): 
    10271027                jid = array[0] 
    10281028                gmail_new_messages = int(array[1]) 
     1029                gmail_messages_list = array[2] 
    10291030                if gajim.config.get('notify_on_new_gmail_email'): 
    10301031                        img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    10311032                                'single_msg_recv.png') #FIXME: find a better image 
    10321033                        title = _('New E-mail on %(gmail_mail_address)s') % \ 
    10331034                                {'gmail_mail_address': jid} 
    10341035                        text = i18n.ngettext('You have %d new E-mail message', 'You have %d new E-mail messages', gmail_new_messages, gmail_new_messages, gmail_new_messages) 
     1036                         
     1037                        if gajim.config.get('notify_on_new_gmail_email_extra'): 
     1038                                for gmessage in gmail_messages_list: 
     1039                                        # each message has a 'From', 'Subject' and 'Snippet' field 
     1040                                        text += _('\nFrom: %(from_address)s') % \ 
     1041                                                {'from_address': gmessage['From']} 
     1042                                         
    10351043                        path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
    10361044                        notify.popup(_('New E-mail'), jid, account, 'gmail', 
    10371045                                path_to_image = path, title = title, text = text) 
  • src/common/config.py

     
    126126                'after_nickname': [ opt_str, ':' ], 
    127127                'send_os_info': [ opt_bool, True ], 
    128128                'notify_on_new_gmail_email': [ opt_bool, True ], 
     129                'notify_on_new_gmail_email_extra': [ opt_bool, True ], 
    129130                'usegpg': [ opt_bool, False, '', True ], 
    130131                'use_gpg_agent': [ opt_bool, False ], 
    131132                'change_roster_title': [ opt_bool, True, _('Add * and [n] in roster title?')], 
  • src/common/connection_handlers.py

     
    12391239                        newmsgs = gm.getTag('mailbox').getAttr('total-matched') 
    12401240                        if newmsgs != '0': 
    12411241                                # there are new messages 
     1242                                if gm.getTag('mailbox').getTag('mail-thread-info'): 
     1243                                        gmail_messages = gm.getTag('mailbox').getTags('mail-thread-info') 
     1244                                        gmail_messages_list = [] 
     1245                                        for gmessage in gmail_messages: 
     1246                                                gmail_from = gmessage.getTag('senders').getTag('sender').getAttr('address') 
     1247                                                gmail_subject = gmessage.getTag('subject').getData() 
     1248                                                gmail_snippet = gmessage.getTag('snippet').getData() 
     1249                                                gmail_messages_list.append({ \ 
     1250                                                        'From': gmail_from, \ 
     1251                                                        'Subject': gmail_subject, \ 
     1252                                                        'Snippet': gmail_snippet}) 
    12421253                                jid = gajim.get_jid_from_account(self.name) 
    12431254                                gajim.log.debug(('You have %s new gmail e-mails on %s.') % (newmsgs, jid)) 
    1244                                 self.dispatch('GMAIL_NOTIFY', (jid, newmsgs)) 
     1255                                self.dispatch('GMAIL_NOTIFY', (jid, newmsgs, gmail_messages_list)) 
    12451256                        raise common.xmpp.NodeProcessed 
    12461257 
    12471258        def _messageCB(self, con, msg): 
  • data/glade/preferences_window.glade

     
    31643164                              <property name="fill">False</property> 
    31653165                            </packing> 
    31663166                          </child> 
     3167 
     3168                          <child> 
     3169                            <widget class="GtkCheckButton" id="notify_gmail_extra_checkbutton"> 
     3170                              <property name="can_focus">True</property> 
     3171                              <property name="label" translatable="yes">Display _extra email details</property> 
     3172                              <property name="use_underline">True</property> 
     3173                              <property name="relief">GTK_RELIEF_NORMAL</property> 
     3174                              <property name="focus_on_click">True</property> 
     3175                              <property name="active">False</property> 
     3176                              <property name="inconsistent">False</property> 
     3177                              <property name="draw_indicator">True</property> 
     3178                              <signal name="toggled" handler="on_notify_gmail_extra_checkbutton_toggled" last_modification_time="Wed, 06 Apr 2005 14:43:56 GMT"/>                                
     3179                            </widget> 
     3180                            <packing> 
     3181                              <property name="padding">0</property> 
     3182                              <property name="expand">False</property> 
     3183                              <property name="fill">False</property> 
     3184                            </packing> 
     3185                          </child> 
    31673186                        </widget> 
    31683187                      </child> 
    31693188                    </widget>