Yann Leboulanger pushed to branch gajim_0.16 at gajim / gajim

Commits:

6 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -9,7 +9,8 @@ stages:
    9 9
     run-test:
    
    10 10
       stage: test
    
    11 11
       script:
    
    12
    -    - make test
    
    12
    +    - ./autogen.sh
    
    13
    +    - make test_nogui
    
    13 14
     
    
    14 15
     run-build:
    
    15 16
       stage: build
    

  • Makefile.am
    ... ... @@ -53,6 +53,10 @@ test:
    53 53
     	python test/runtests.py
    
    54 54
     .PHONY: test
    
    55 55
     
    
    56
    +test_nogui:
    
    57
    +	python test/runtests.py -n
    
    58
    +.PHONY: test_nogui
    
    59
    +
    
    56 60
     doc:
    
    57 61
     	epydoc --config=doc/epydoc.conf
    
    58 62
     .PHONY: doc

  • src/common/connection_handlers_events.py
    ... ... @@ -41,8 +41,6 @@ from nbxmpp.protocol import NS_CHATSTATES
    41 41
     from common.jingle_transport import JingleTransportSocks5
    
    42 42
     from common.file_props import FilesProp
    
    43 43
     
    
    44
    -import gtkgui_helpers
    
    45
    -
    
    46 44
     if gajim.HAVE_PYOPENSSL:
    
    47 45
         import OpenSSL.crypto
    
    48 46
     
    
    ... ... @@ -2484,8 +2482,6 @@ class NotificationEvent(nec.NetworkIncomingEvent):
    2484 2482
                 self.popup_title = _('New Message from %(nickname)s') % \
    
    2485 2483
                     {'nickname': nick}
    
    2486 2484
     
    
    2487
    -        self.popup_image = gtkgui_helpers.get_icon_path(self.popup_image, 48)
    
    2488
    -
    
    2489 2485
             if not gajim.config.get('notify_on_new_message') or \
    
    2490 2486
             not self.first_unread:
    
    2491 2487
                 self.do_popup = False
    
    ... ... @@ -2541,6 +2537,29 @@ class NotificationEvent(nec.NetworkIncomingEvent):
    2541 2537
     
    
    2542 2538
             self.do_popup = False
    
    2543 2539
     
    
    2540
    +    def get_path_to_generic_or_avatar(generic, jid=None, suffix=None):
    
    2541
    +        """
    
    2542
    +        Choose between avatar image and default image
    
    2543
    +
    
    2544
    +        Returns full path to the avatar image if it exists, otherwise returns
    
    2545
    +        full path to the image.  generic must be with extension and suffix
    
    2546
    +        without
    
    2547
    +        """
    
    2548
    +        if jid:
    
    2549
    +            # we want an avatar
    
    2550
    +            puny_jid = helpers.sanitize_filename(jid)
    
    2551
    +            path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + suffix
    
    2552
    +            path_to_local_file = path_to_file + '_local'
    
    2553
    +            for extension in ('.png', '.jpeg'):
    
    2554
    +                path_to_local_file_full = path_to_local_file + extension
    
    2555
    +                if os.path.exists(path_to_local_file_full):
    
    2556
    +                    return path_to_local_file_full
    
    2557
    +            for extension in ('.png', '.jpeg'):
    
    2558
    +                path_to_file_full = path_to_file + extension
    
    2559
    +                if os.path.exists(path_to_file_full):
    
    2560
    +                    return path_to_file_full
    
    2561
    +        return os.path.abspath(generic)
    
    2562
    +
    
    2544 2563
         def handle_incoming_pres_event(self, pres_obj):
    
    2545 2564
             if gajim.jid_is_transport(pres_obj.jid):
    
    2546 2565
                 return True
    
    ... ... @@ -2619,8 +2638,8 @@ class NotificationEvent(nec.NetworkIncomingEvent):
    2619 2638
                 iconset = gajim.config.get('iconset')
    
    2620 2639
                 img_path = os.path.join(helpers.get_iconset_path(iconset),
    
    2621 2640
                     '48x48', show_image)
    
    2622
    -        self.popup_image = gtkgui_helpers.get_path_to_generic_or_avatar(
    
    2623
    -            img_path, jid=self.jid, suffix=suffix)
    
    2641
    +        self.popup_image_path = self.get_path_to_generic_or_avatar(img_path,
    
    2642
    +            jid=self.jid, suffix=suffix)
    
    2624 2643
     
    
    2625 2644
             self.popup_timeout = gajim.config.get('notification_timeout')
    
    2626 2645
     
    
    ... ... @@ -2666,6 +2685,7 @@ class NotificationEvent(nec.NetworkIncomingEvent):
    2666 2685
             self.popup_event_type = ''
    
    2667 2686
             self.popup_msg_type = ''
    
    2668 2687
             self.popup_image = ''
    
    2688
    +        self.popup_image_path = ''
    
    2669 2689
             self.popup_timeout = -1
    
    2670 2690
     
    
    2671 2691
             self.do_command = False
    

  • src/gtkgui_helpers.py
    ... ... @@ -642,28 +642,6 @@ def make_pixbuf_grayscale(pixbuf):
    642 642
         pixbuf.saturate_and_pixelate(pixbuf2, 0.0, False)
    
    643 643
         return pixbuf2
    
    644 644
     
    
    645
    -def get_path_to_generic_or_avatar(generic, jid = None, suffix = None):
    
    646
    -    """
    
    647
    -    Choose between avatar image and default image
    
    648
    -
    
    649
    -    Returns full path to the avatar image if it exists, otherwise returns full
    
    650
    -    path to the image.  generic must be with extension and suffix without
    
    651
    -    """
    
    652
    -    if jid:
    
    653
    -        # we want an avatar
    
    654
    -        puny_jid = helpers.sanitize_filename(jid)
    
    655
    -        path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid) + suffix
    
    656
    -        path_to_local_file = path_to_file + '_local'
    
    657
    -        for extension in ('.png', '.jpeg'):
    
    658
    -            path_to_local_file_full = path_to_local_file + extension
    
    659
    -            if os.path.exists(path_to_local_file_full):
    
    660
    -                return path_to_local_file_full
    
    661
    -        for extension in ('.png', '.jpeg'):
    
    662
    -            path_to_file_full = path_to_file + extension
    
    663
    -            if os.path.exists(path_to_file_full):
    
    664
    -                return path_to_file_full
    
    665
    -    return os.path.abspath(generic)
    
    666
    -
    
    667 645
     def decode_filechooser_file_paths(file_paths):
    
    668 646
         """
    
    669 647
         Decode as UTF-8 under Windows and ask sys.getfilesystemencoding() in POSIX
    

  • src/notify.py
    ... ... @@ -155,8 +155,16 @@ class Notification:
    155 155
     
    
    156 156
         def _nec_notification(self, obj):
    
    157 157
             if obj.do_popup:
    
    158
    +            if obj.popup_image:
    
    159
    +                icon_path = gtkgui_helpers.get_icon_path(obj.popup_image, 48)
    
    160
    +                if icon_path:
    
    161
    +                    image_path = icon_path
    
    162
    +            elif obj.popup_image_path:
    
    163
    +                image_path = obj.popup_image_path
    
    164
    +            else:
    
    165
    +                image_path = ''
    
    158 166
                 popup(obj.popup_event_type, obj.jid, obj.conn.name,
    
    159
    -                obj.popup_msg_type, path_to_image=obj.popup_image,
    
    167
    +                obj.popup_msg_type, path_to_image=image_path,
    
    160 168
                     title=obj.popup_title, text=obj.popup_text,
    
    161 169
                     timeout=obj.popup_timeout)
    
    162 170
     
    

  • test/runtests.py
    ... ... @@ -39,7 +39,6 @@ modules = ( 'unit.test_protocol_caps',
    39 39
                 'unit.test_caps_cache',
    
    40 40
                 'unit.test_contacts',
    
    41 41
                 'unit.test_account',
    
    42
    -            'unit.test_gui_interface',
    
    43 42
               )
    
    44 43
     
    
    45 44
     if use_x:
    
    ... ... @@ -47,6 +46,7 @@ if use_x:
    47 46
                      #'integration.test_gui_event_integration',
    
    48 47
                      'integration.test_roster',
    
    49 48
                      'integration.test_resolver',
    
    49
    +                 'unit.test_gui_interface',
    
    50 50
                    )
    
    51 51
     
    
    52 52
     nb_errors = 0