Ticket #2378: gajim-icontheme.patch

File gajim-icontheme.patch, 15.3 KB (added by Patryk Zawadzki <patrys@…>, 3 years ago)

first patch to use native gtk icon themes

  • src/config.py

    diff -ur /usr/share/gajim/src/config.py ../BUILD/gajim-0.10.1.6/src/config.py
    old new  
    30213021                self.go_online_checkbutton.show() 
    30223022                self.show_vcard_checkbutton.show() 
    30233023                img = self.xml.get_widget('finish_image') 
    3024                 path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps', 'gajim.png') 
     3024                path_to_file = gtkgui_helpers.get_icon_path('gajim.png', 48) 
    30253025                img.set_from_file(path_to_file) 
    30263026 
    30273027                finish_text = '<big><b>%s</b></big>\n\n%s' % ( 
  • src/dialogs.py

    diff -ur /usr/share/gajim/src/dialogs.py ../BUILD/gajim-0.10.1.6/src/dialogs.py
    old new  
    767767                if gtk.pygtk_version >= (2, 8, 0) and gtk.gtk_version >= (2, 8, 0): 
    768768                        dlg.props.wrap_license = True 
    769769 
    770                 pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join( 
    771                         gajim.DATA_DIR, 'pixmaps', 'gajim_about.png'))                   
     770                pixbuf = gtkgui_helpers.get_icon_pixmap('gajim-about', 64) 
    772771 
    773772                dlg.set_logo(pixbuf) 
    774773                #here you write your name in the form Name FamilyName <someone@somewhere> 
     
    13421341 
    13431342                # default image 
    13441343                if not path_to_image: 
    1345                         path_to_image = os.path.abspath( 
    1346                                 os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    1347                                         'chat_msg_recv.png')) # img to display 
     1344                        path_to_image = gtkgui_helpers.get_icon_path('chat_msg_recv.png', 48) # img to display 
    13481345 
    13491346                if event_type == _('Contact Signed In'): 
    13501347                        bg_color = 'limegreen' 
  • src/gajim.py

    diff -ur /usr/share/gajim/src/gajim.py ../BUILD/gajim-0.10.1.6/src/gajim.py
    old new  
    153153pid_filename += '.pid' 
    154154import dialogs 
    155155if os.path.exists(pid_filename): 
    156         path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png') 
    157         pix = gtk.gdk.pixbuf_new_from_file(path_to_file) 
     156        pix = gtkgui_helpers.get_icon_pixmap('gajim') 
    158157        gtk.window_set_default_icon(pix) # set the icon to all newly opened wind 
    159158        pritext = _('Gajim is already running') 
    160159        sectext = _('Another instance of Gajim seems to be running\nRun anyway?') 
     
    301300 
    302301        def handle_event_connection_lost(self, account, array): 
    303302                # ('CONNECTION_LOST', account, [title, text]) 
    304                 path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    305                         'connection_lost.png') 
    306                 path = gtkgui_helpers.get_path_to_generic_or_avatar(path) 
     303                image = gtkgui_helpers.get_icon_path('gajim-connection_lost', 48) 
     304                path = gtkgui_helpers.get_path_to_generic_or_avatar(image) 
    307305                notify.popup(_('Connection Failed'), account, account, 
    308306                        'connection_failed', path, array[0], array[1]) 
    309307 
     
    973971                        array[3])) 
    974972 
    975973                if helpers.allow_showing_notification(account, 'notify_on_new_message'): 
    976                         path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    977                                 'gc_invitation.png') 
     974                        path = gtkgui_helpers.get_icon_path('gajim-gc_invitation.png', 48) 
    978975                        path = gtkgui_helpers.get_path_to_generic_or_avatar(path) 
    979976                        event_type = _('Groupchat Invitation') 
    980977                        notify.popup(event_type, jid, account, 'gc-invitation', path, 
     
    10761073                self.add_event(account, jid, 'file-send-error', file_props) 
    10771074 
    10781075                if helpers.allow_showing_notification(account): 
    1079                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png') 
     1076                        img = gtkhui_helpers.get_icon_path('gajim-ft_error', 48) 
    10801077                        path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
    10811078                        event_type = _('File Transfer Error') 
    10821079                        notify.popup(event_type, jid, account, 'file-send-error', path, 
     
    10871084                gmail_new_messages = int(array[1]) 
    10881085                gmail_messages_list = array[2] 
    10891086                if gajim.config.get('notify_on_new_gmail_email'): 
    1090                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    1091                                 'new_email_recv.png') 
     1087                        img = gtkgui_helpers.get_image_path('gajim-new_email_recv', 48) 
    10921088                        title = _('New mail on %(gmail_mail_address)s') % \ 
    10931089                                {'gmail_mail_address': jid} 
    10941090                        text = i18n.ngettext('You have %d new mail conversation', 
     
    12111207 
    12121208                if helpers.allow_showing_notification(account): 
    12131209                        # check if we should be notified 
    1214                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png') 
    1215  
     1210                        img = gtkgui_helpers.get_icon_path('gajim-ft_error', 48) 
    12161211                        path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
    12171212                        event_type = _('File Transfer Error') 
    12181213                        notify.popup(event_type, jid, account, msg_type, path, 
     
    12331228                self.add_event(account, jid, 'file-request', file_props) 
    12341229 
    12351230                if helpers.allow_showing_notification(account): 
    1236                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    1237                                 'ft_request.png') 
     1231                        img = gtkgui_helpers.get_icon_path('gajim-ft_request', 48) 
    12381232                        txt = _('%s wants to send you a file.') % gajim.get_name_from_jid( 
    12391233                                account, jid) 
    12401234                        path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
     
    12991293                                if event_type == _('File Transfer Completed'): 
    13001294                                        txt = _('You successfully received %(filename)s from %(name)s.')\ 
    13011295                                                % {'filename': filename, 'name': name} 
    1302                                         img = 'ft_done.png' 
     1296                                        img = 'gajim-ft_done' 
    13031297                                else: # ft stopped 
    13041298                                        txt = _('File transfer of %(filename)s from %(name)s stopped.')\ 
    13051299                                                % {'filename': filename, 'name': name} 
    1306                                         img = 'ft_stopped.png' 
     1300                                        img = 'gajim-ft_stopped' 
    13071301                        else: 
    13081302                                receiver = file_props['receiver'] 
    13091303                                if hasattr(receiver, 'jid'): 
     
    13161310                                if event_type == _('File Transfer Completed'): 
    13171311                                        txt = _('You successfully sent %(filename)s to %(name)s.')\ 
    13181312                                                % {'filename': filename, 'name': name} 
    1319                                         img = 'ft_done.png' 
     1313                                        img = 'gajim-ft_done' 
    13201314                                else: # ft stopped 
    13211315                                        txt = _('File transfer of %(filename)s to %(name)s stopped.')\ 
    13221316                                                % {'filename': filename, 'name': name} 
    1323                                         img = 'ft_stopped.png' 
    1324                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', img) 
     1317                                        img = 'gajim-ft_stopped' 
     1318                        img = gtkgui_helpers.get_icon_path(img, 48) 
    13251319                        path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
    13261320                else: 
    13271321                        txt = '' 
     
    19471941 
    19481942                self.show_vcard_when_connect = [] 
    19491943 
    1950                 path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png') 
    1951                 pix = gtk.gdk.pixbuf_new_from_file(path_to_file) 
     1944                pix = gtkgui_helpers.get_icon_pixmap('gajim') 
     1945                path_to_file = gtkgui_helpers.get_icon_path('gajim') 
    19521946                gtk.window_set_default_icon(pix) # set the icon to all newly opened windows 
    19531947                self.roster.window.set_icon_from_file(path_to_file) # and to roster window 
    19541948                self.sleeper = common.sleepy.Sleepy( 
  • src/gtkgui_helpers.py

    diff -ur /usr/share/gajim/src/gtkgui_helpers.py ../BUILD/gajim-0.10.1.6/src/gtkgui_helpers.py
    old new  
    4848screen_w = gtk.gdk.screen_width() 
    4949screen_h = gtk.gdk.screen_height() 
    5050 
     51gtk_icon_theme = gtk.icon_theme_get_default() 
     52 
     53def get_icon_pixmap(icon_name, size = 16): 
     54        try: 
     55                return gtk_icon_theme.load_icon(icon_name, size, 0) 
     56        except gobject.GError, e: 
     57                print ("Unable to load icon %s" % icon_name), e 
     58 
     59def get_icon_path(icon_name, size = 16): 
     60        try: 
     61                icon_info = gtk_icon_theme.lookup_icon(icon_name, size, 0) 
     62                if icon_info == None: 
     63                        print "Icon not found: %s" % icon_name 
     64                        return "" 
     65                else: 
     66                        return icon_info.get_filename() 
     67        except gobject.GError, e: 
     68                print ("Unable to find icon %s" % icon_name), e 
     69 
    5170GLADE_DIR = os.path.join('..', 'data', 'glade') 
    5271def get_glade(file_name, root = None): 
    5372        file_path = os.path.join(GLADE_DIR, file_name) 
  • src/history_manager.py

    diff -ur /usr/share/gajim/src/history_manager.py ../BUILD/gajim-0.10.1.6/src/history_manager.py
    old new  
    5656 
    5757class HistoryManager: 
    5858        def __init__(self): 
    59                 path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png') 
     59                path_to_file = gtkgui_helpers.get_icon_path('gajim') 
    6060                pix = gtk.gdk.pixbuf_new_from_file(path_to_file) 
    6161                gtk.window_set_default_icon(pix) # set the icon to all newly opened windows 
    6262                 
  • src/notify.py

    diff -ur /usr/share/gajim/src/notify.py ../BUILD/gajim-0.10.1.6/src/notify.py
    old new  
    201201                                if status_message: 
    202202                                        text =  text + " : " + status_message 
    203203                                popup(_('Contact Changed Status'), jid, account, 
    204                                         path_to_image = path, title = title, text = text) 
     204                                        image = path, title = title, text = text) 
    205205                        elif event == 'contact_connected': 
    206206                                title = _('%(nickname)s Signed In') % \ 
    207207                                        {'nickname': gajim.get_name_from_jid(account, jid)} 
     
    209209                                if status_message: 
    210210                                        text = status_message 
    211211                                popup(_('Contact Signed In'), jid, account, 
    212                                         path_to_image = path, title = title, text = text) 
     212                                        image = path, title = title, text = text) 
    213213                        elif event == 'contact_disconnected': 
    214214                                title = _('%(nickname)s Signed Out') % \ 
    215215                                        {'nickname': gajim.get_name_from_jid(account, jid)} 
     
    217217                                if status_message: 
    218218                                        text = status_message 
    219219                                popup(_('Contact Signed Out'), jid, account, 
    220                                         path_to_image = path, title = title, text = text) 
     220                                        image = path, title = title, text = text) 
    221221                elif event == 'new_message': 
    222222                        if message_type == 'normal': # single message 
    223223                                event_type = _('New Single Message') 
    224                                 img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    225                                         'single_msg_recv.png') 
     224                                img = 'gajim-single_msg_recv' 
    226225                                title = _('New Single Message from %(nickname)s') % \ 
    227226                                        {'nickname': nickname} 
    228227                                text = message 
    229228                        elif message_type == 'pm': # private message 
    230229                                event_type = _('New Private Message') 
    231230                                room_name = gajim.get_nick_from_jid(jid) 
    232                                 img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    233                                         'priv_msg_recv.png') 
     231                                img = 'gajim-priv_msg_recv' 
    234232                                title = _('New Private Message from group chat %s') % room_name 
    235233                                text = _('%(nickname)s: %(message)s') % {'nickname': nickname, 
    236234                                        'message': message} 
    237235                        else: # chat message 
    238236                                event_type = _('New Message') 
    239                                 img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    240                                         'chat_msg_recv.png') 
     237                                img = 'gajim-chat_msg_recv.png' 
    241238                                title = _('New Message from %(nickname)s') % \ 
    242239                                        {'nickname': nickname} 
    243240                                text = message 
    244                         path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
    245241                        popup(event_type, jid, account, message_type, 
    246                                 path_to_image = path, title = title, text = text) 
     242                                image = img, title = title, text = text) 
    247243 
    248244        if do_sound: 
    249245                snd_file = None 
     
    275271                except: 
    276272                        pass 
    277273 
    278 def popup(event_type, jid, account, msg_type = '', path_to_image = None, 
     274def popup(event_type, jid, account, msg_type = '', image = None, 
    279275        title = None, text = None): 
    280276        '''Notifies a user of an event. It first tries to a valid implementation of 
    281277        the Desktop Notification Specification. If that fails, then we fall back to 
     
    286282        if gajim.config.get('use_notif_daemon') and dbus_support.supported: 
    287283                try: 
    288284                        DesktopNotification(event_type, jid, account, msg_type, 
    289                                 path_to_image, title, text) 
     285                                image, title, text) 
    290286                        return  # sucessfully did D-Bus Notification procedure! 
    291287                except dbus.dbus_bindings.DBusException, e: 
    292288                        # Connection to D-Bus failed 
     
    301297                if not title: 
    302298                        title = event_type 
    303299                # default image 
    304                 if not path_to_image: 
    305                         path_to_image = os.path.abspath( 
    306                                 os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    307                                         'chat_msg_recv.png')) # img to display 
     300                if not image: 
     301                        path_to_image = gtkgui_helpers.get_icon_path('gajim-chat_msg_recv', 48) # img to display 
     302                else: 
     303                        path_to_image = gtkgui_helpers.get_icon_path(image, 48) 
    308304                 
    309305                 
    310306                notification = pynotify.Notification(title, text) 
     
    433429                        ntype = 'connection.failed' 
    434430                else: 
    435431                        # default failsafe values 
    436                         self.path_to_image = os.path.abspath( 
    437                                 os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    438                                         'chat_msg_recv.png')) # img to display 
     432                        self.path_to_image = gtkgui_helpers.get_icon_path('gajim-chat_msg_recv', 48) # img to display 
    439433                        ntype = 'im' # Notification Type 
    440434 
    441435                self.notif = dbus_support.get_notifications_interface() 
  • src/roster_window.py

    diff -ur /usr/share/gajim/src/roster_window.py ../BUILD/gajim-0.10.1.6/src/roster_window.py
    old new  
    14171417 
    14181418                        if not our_jid: 
    14191419                                # add a special img for rename menuitem 
    1420                                 path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1421                                         'kbd_input.png') 
     1420                                path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    14221421                                img = gtk.Image() 
    14231422                                img.set_from_file(path_to_kbd_input_img) 
    14241423                                rename_menuitem.set_image(img) 
     
    15361535 
    15371536                if not our_jid: 
    15381537                        # add a special img for rename menuitem 
    1539                         path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1540                                 'kbd_input.png') 
     1538                        path_to_kbd_input_img = gtkgui_helpers.get_icon_path('kbd_input.png') 
    15411539                        img = gtk.Image() 
    15421540                        img.set_from_file(path_to_kbd_input_img) 
    15431541                        rename_menuitem.set_image(img) 
     
    18291827 
    18301828                rename_item = gtk.ImageMenuItem(_('Re_name')) 
    18311829                # add a special img for rename menuitem 
    1832                 path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1833                         'kbd_input.png') 
     1830                path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    18341831                img = gtk.Image() 
    18351832                img.set_from_file(path_to_kbd_input_img) 
    18361833                rename_item.set_image(img) 
     
    18901887                 
    18911888                item = gtk.ImageMenuItem(_('_Rename')) 
    18921889                # add a special img for rename menuitem 
    1893                 path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1894                         'kbd_input.png') 
     1890                path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    18951891                img = gtk.Image() 
    18961892                img.set_from_file(path_to_kbd_input_img) 
    18971893                item.set_image(img) 
     
    19761972                        sub_menu.append(item) 
    19771973 
    19781974                        item = gtk.ImageMenuItem(_('_Change Status Message')) 
    1979                         path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     1975                        path = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    19801976                        img = gtk.Image() 
    19811977                        img.set_from_file(path) 
    19821978                        item.set_image(img) 
     
    20382034                        sub_menu.append(item) 
    20392035 
    20402036                        item = gtk.ImageMenuItem(_('_Change Status Message')) 
    2041                         path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     2037                        path = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    20422038                        img = gtk.Image() 
    20432039                        img.set_from_file(path) 
    20442040                        item.set_image(img) 
     
    40674063                # Add a Separator (self.iter_is_separator() checks on string SEPARATOR) 
    40684064                liststore.append(['SEPARATOR', None, '', True]) 
    40694065 
    4070                 path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     4066                path = gtk_gui_helpers.get_icon_path('gajim-kbd_input') 
    40714067                img = gtk.Image() 
    40724068                img.set_from_file(path) 
    40734069                # sensitivity to False because by default we're offline 
  • src/systray.py

    diff -ur /usr/share/gajim/src/systray.py ../BUILD/gajim-0.10.1.6/src/systray.py
    old new  
    139139                sub_menu.append(item) 
    140140 
    141141                item = gtk.ImageMenuItem(_('_Change Status Message...')) 
    142                 path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     142                path = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    143143                img = gtk.Image() 
    144144                img.set_from_file(path) 
    145145                item.set_image(img)