Ticket #2378: gajim-icontheme2.patch

File gajim-icontheme2.patch, 16.3 kB (added by jim++, 2 years ago)

Same patch with fixs

  • src/history_manager.py

     
    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/roster_window.py

     
    14621462 
    14631463                        if not our_jid: 
    14641464                                # add a special img for rename menuitem 
    1465                                 path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1466                                         'kbd_input.png') 
     1465                                path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    14671466                                img = gtk.Image() 
    14681467                                img.set_from_file(path_to_kbd_input_img) 
    14691468                                rename_menuitem.set_image(img) 
     
    15811580 
    15821581                if not our_jid: 
    15831582                        # add a special img for rename menuitem 
    1584                         path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1585                                 'kbd_input.png') 
     1583                        path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    15861584                        img = gtk.Image() 
    15871585                        img.set_from_file(path_to_kbd_input_img) 
    15881586                        rename_menuitem.set_image(img) 
     
    18741872 
    18751873                rename_item = gtk.ImageMenuItem(_('Re_name')) 
    18761874                # add a special img for rename menuitem 
    1877                 path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1878                         'kbd_input.png') 
     1875                path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    18791876                img = gtk.Image() 
    18801877                img.set_from_file(path_to_kbd_input_img) 
    18811878                rename_item.set_image(img) 
     
    19351932                 
    19361933                item = gtk.ImageMenuItem(_('_Rename')) 
    19371934                # add a special img for rename menuitem 
    1938                 path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 
    1939                         'kbd_input.png') 
     1935                path_to_kbd_input_img = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    19401936                img = gtk.Image() 
    19411937                img.set_from_file(path_to_kbd_input_img) 
    19421938                item.set_image(img) 
     
    20212017                        sub_menu.append(item) 
    20222018 
    20232019                        item = gtk.ImageMenuItem(_('_Change Status Message')) 
    2024                         path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     2020                        path = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    20252021                        img = gtk.Image() 
    20262022                        img.set_from_file(path) 
    20272023                        item.set_image(img) 
     
    20832079                        sub_menu.append(item) 
    20842080 
    20852081                        item = gtk.ImageMenuItem(_('_Change Status Message')) 
    2086                         path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     2082                        path = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    20872083                        img = gtk.Image() 
    20882084                        img.set_from_file(path) 
    20892085                        item.set_image(img) 
     
    40854081                # Add a Separator (self.iter_is_separator() checks on string SEPARATOR) 
    40864082                liststore.append(['SEPARATOR', None, '', True]) 
    40874083 
    4088                 path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     4084                path = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    40894085                img = gtk.Image() 
    40904086                img.set_from_file(path) 
    40914087                # sensitivity to False because by default we're offline 
  • src/config.py

     
    30253025                self.go_online_checkbutton.show() 
    30263026                self.show_vcard_checkbutton.show() 
    30273027                img = self.xml.get_widget('finish_image') 
    3028                 path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps', 'gajim.png') 
     3028                path_to_file = gtkgui_helpers.get_icon_path('gajim.png', 48) 
    30293029                img.set_from_file(path_to_file) 
    30303030 
    30313031                finish_text = '<big><b>%s</b></big>\n\n%s' % ( 
  • src/notify.py

     
    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/systray.py

     
    140140                sub_menu.append(item) 
    141141 
    142142                item = gtk.ImageMenuItem(_('_Change Status Message...')) 
    143                 path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'kbd_input.png') 
     143                path = gtkgui_helpers.get_icon_path('gajim-kbd_input') 
    144144                img = gtk.Image() 
    145145                img.set_from_file(path) 
    146146                item.set_image(img) 
  • src/dialogs.py

     
    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

     
    150150pid_filename += '.pid' 
    151151import dialogs 
    152152if os.path.exists(pid_filename): 
    153         path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png') 
    154         pix = gtk.gdk.pixbuf_new_from_file(path_to_file) 
     153        pix = gtkgui_helpers.get_icon_pixmap('gajim') 
    155154        gtk.window_set_default_icon(pix) # set the icon to all newly opened wind 
    156155        pritext = _('Gajim is already running') 
    157156        sectext = _('Another instance of Gajim seems to be running\nRun anyway?') 
     
    298297 
    299298        def handle_event_connection_lost(self, account, array): 
    300299                # ('CONNECTION_LOST', account, [title, text]) 
    301                 path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    302                         'connection_lost.png') 
    303                 path = gtkgui_helpers.get_path_to_generic_or_avatar(path) 
     300                image = gtkgui_helpers.get_icon_path('gajim-connection_lost', 48) 
    304301                notify.popup(_('Connection Failed'), account, account, 
    305                         'connection_failed', path, array[0], array[1]) 
     302                        'connection_failed', image, array[0], array[1]) 
    306303 
    307304        def unblock_signed_in_notifications(self, account): 
    308305                gajim.block_signed_in_notifications[account] = False 
     
    973970                        array[3])) 
    974971 
    975972                if helpers.allow_showing_notification(account): 
    976                         path = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    977                                 'gc_invitation.png') 
    978                         path = gtkgui_helpers.get_path_to_generic_or_avatar(path) 
     973                        path = gtkgui_helpers.get_icon_path('gajim-gc_invitation.png', 48) 
    979974                        event_type = _('Groupchat Invitation') 
    980975                        notify.popup(event_type, jid, account, 'gc-invitation', path, 
    981976                                event_type, room_jid) 
     
    10761071                self.add_event(account, jid, 'file-send-error', file_props) 
    10771072 
    10781073                if helpers.allow_showing_notification(account): 
    1079                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png') 
    1080                         path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
     1074                        img = gtkhui_helpers.get_icon_path('gajim-ft_error', 48) 
    10811075                        event_type = _('File Transfer Error') 
    1082                         notify.popup(event_type, jid, account, 'file-send-error', path, 
     1076                        notify.popup(event_type, jid, account, 'file-send-error', img, 
    10831077                                event_type, file_props['name']) 
    10841078 
    10851079        def handle_event_gmail_notify(self, account, array): 
     
    10871081                gmail_new_messages = int(array[1]) 
    10881082                gmail_messages_list = array[2] 
    10891083                if gajim.config.get('notify_on_new_gmail_email'): 
    1090                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    1091                                 'new_email_recv.png') 
     1084                        img = gtkgui_helpers.get_image_path('gajim-new_email_recv', 48) 
    10921085                        title = _('New mail on %(gmail_mail_address)s') % \ 
    10931086                                {'gmail_mail_address': jid} 
    10941087                        text = i18n.ngettext('You have %d new mail conversation', 
     
    11031096                                        text += _('\nFrom: %(from_address)s') % \ 
    11041097                                                {'from_address': gmessage['From']} 
    11051098                                         
    1106                         path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
    11071099                        notify.popup(_('New E-mail'), jid, account, 'gmail', 
    1108                                 path_to_image = path, title = title, text = text) 
     1100                                image = img, title = title, text = text) 
    11091101 
    11101102                if self.remote_ctrl: 
    11111103                        self.remote_ctrl.raise_signal('NewGmail', (account, array)) 
     
    12181210 
    12191211                if helpers.allow_showing_notification(account): 
    12201212                        # check if we should be notified 
    1221                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 'ft_error.png') 
    1222  
    1223                         path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
     1213                        img = gtkgui_helpers.get_icon_path('gajim-ft_error', 48) 
    12241214                        event_type = _('File Transfer Error') 
    1225                         notify.popup(event_type, jid, account, msg_type, path, 
     1215                        notify.popup(event_type, jid, account, msg_type, img, 
    12261216                                title = event_type, text = file_props['name']) 
    12271217 
    12281218        def handle_event_file_request(self, account, array): 
     
    12401230                self.add_event(account, jid, 'file-request', file_props) 
    12411231 
    12421232                if helpers.allow_showing_notification(account): 
    1243                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', 
    1244                                 'ft_request.png') 
     1233                        img = gtkgui_helpers.get_icon_path('gajim-ft_request', 48) 
    12451234                        txt = _('%s wants to send you a file.') % gajim.get_name_from_jid( 
    12461235                                account, jid) 
    1247                         path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
    12481236                        event_type = _('File Transfer Request') 
    12491237                        notify.popup(event_type, jid, account, 'file-request', 
    1250                                 path_to_image = path, title = event_type, text = txt) 
     1238                                image = img, title = event_type, text = txt) 
    12511239 
    12521240        def handle_event_file_progress(self, account, file_props): 
    12531241                self.instances['file_transfers'].set_progress(file_props['type'],  
     
    13061294                                if event_type == _('File Transfer Completed'): 
    13071295                                        txt = _('You successfully received %(filename)s from %(name)s.')\ 
    13081296                                                % {'filename': filename, 'name': name} 
    1309                                         img = 'ft_done.png' 
     1297                                        img = 'gajim-ft_done' 
    13101298                                else: # ft stopped 
    13111299                                        txt = _('File transfer of %(filename)s from %(name)s stopped.')\ 
    13121300                                                % {'filename': filename, 'name': name} 
    1313                                         img = 'ft_stopped.png' 
     1301                                        img = 'gajim-ft_stopped' 
    13141302                        else: 
    13151303                                receiver = file_props['receiver'] 
    13161304                                if hasattr(receiver, 'jid'): 
     
    13231311                                if event_type == _('File Transfer Completed'): 
    13241312                                        txt = _('You successfully sent %(filename)s to %(name)s.')\ 
    13251313                                                % {'filename': filename, 'name': name} 
    1326                                         img = 'ft_done.png' 
     1314                                        img = 'gajim-ft_done' 
    13271315                                else: # ft stopped 
    13281316                                        txt = _('File transfer of %(filename)s to %(name)s stopped.')\ 
    13291317                                                % {'filename': filename, 'name': name} 
    1330                                         img = 'ft_stopped.png' 
    1331                         img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'events', img) 
    1332                         path = gtkgui_helpers.get_path_to_generic_or_avatar(img) 
     1318                                        img = 'gajim-ft_stopped' 
     1319                        img = gtkgui_helpers.get_icon_path(img, 48) 
    13331320                else: 
    13341321                        txt = '' 
    13351322 
     
    13381325                        gajim.connections[account].connected in (2, 3)): 
    13391326                        # we want to be notified and we are online/chat or we don't mind 
    13401327                        # bugged when away/na/busy 
    1341                         notify.popup(event_type, jid, account, msg_type, path_to_image = path, 
     1328                        notify.popup(event_type, jid, account, msg_type, image = img, 
    13421329                                title = event_type, text = txt) 
    13431330 
    13441331        def handle_event_stanza_arrived(self, account, stanza): 
     
    19541941 
    19551942                self.show_vcard_when_connect = [] 
    19561943 
    1957                 path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png') 
    1958                 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') 
    19591946                gtk.window_set_default_icon(pix) # set the icon to all newly opened windows 
    19601947                self.roster.window.set_icon_from_file(path_to_file) # and to roster window 
    19611948                self.sleeper = common.sleepy.Sleepy( 
  • src/gtkgui_helpers.py

     
    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)