base of using icon themes. see #2378

This commit is contained in:
Yann Leboulanger 2009-11-27 16:42:32 +01:00
parent aed9690dc5
commit 5b10d8fe5c
10 changed files with 65 additions and 4 deletions

View File

@ -73,6 +73,7 @@ AC_CONFIG_FILES([
data/iconsets/Makefile
data/moods/Makefile
data/activities/Makefile
data/icons/Makefile
data/gajim.desktop.in
data/defs.py
src/Makefile

View File

@ -1,4 +1,4 @@
SUBDIRS = glade emoticons pixmaps iconsets moods activities
SUBDIRS = glade emoticons pixmaps iconsets moods activities icons
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications

38
data/icons/Makefile.am Normal file
View File

@ -0,0 +1,38 @@
iconsdir = $(pkgdatadir)/icons
icons_DATA =
ICONS_DIRS = **/**/**
ICONS_FILES = **/**/**/{*.png,*.svg}
install-data-local:
@for d in $$(cd $(srcdir); echo $(ICONS_DIRS));do \
if test -d $(srcdir)/$$d;then \
echo " $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/icons/$$d"; \
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/icons/$$d || exit 1; \
fi; \
done; \
for f in $$(cd $(srcdir); echo $(ICONS_FILES));do \
if test -f $(srcdir)/$$f; then \
echo " $(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(pkgdatadir)/icons/$$f"; \
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(pkgdatadir)/icons/$$f || exit 1; \
fi; \
done;
dist-hook:
@for d in $$(cd $(srcdir); echo $(ICONS_DIRS));do \
if test -d $(srcdir)/$$d;then \
echo " $(mkdir_p) $(distdir)/$$d"; \
$(mkdir_p) $(distdir)/$$d || exit 1; \
fi; \
done; \
for f in $$(cd $(srcdir); echo $(ICONS_FILES));do \
if test -f $(srcdir)/$$f; then \
echo " cp -pR $(srcdir)/$$f $(distdir)/$$f"; \
cp -pR $(srcdir)/$$f $(distdir)/$$f || exit 1; \
fi; \
done;
MAINTAINERCLEANFILES = Makefile.in

View File

Before

Width:  |  Height:  |  Size: 780 B

After

Width:  |  Height:  |  Size: 780 B

View File

@ -1292,7 +1292,7 @@ class ChatControl(ChatControlBase):
self._send_file_button = self.xml.get_widget('send_file_button')
# add a special img for send file button
path_to_upload_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'upload.png')
path_to_upload_img = gtkgui_helpers.get_icon_path('gajim-upload')
img = gtk.Image()
img.set_from_file(path_to_upload_img)
self._send_file_button.set_image(img)

View File

@ -122,6 +122,7 @@ class ConfigPaths:
if not datadir:
datadir = u'..'
self.add('DATA', os.path.join(datadir, windowsify(u'data')))
self.add('ICONS', os.path.join(datadir, windowsify(u'icons')))
self.add('HOME', fse(os.path.expanduser('~')))
try:
self.add('TMP', fse(tempfile.gettempdir()))

View File

@ -85,6 +85,7 @@ MY_ACTIVITY_ICONSETS_PATH = gajimpaths['MY_ACTIVITY_ICONSETS']
MY_CACERTS = gajimpaths['MY_CACERTS']
TMP = gajimpaths['TMP']
DATA_DIR = gajimpaths['DATA']
ICONS_DIR = gajimpaths['ICONS']
HOME_DIR = gajimpaths['HOME']
try:

View File

@ -2086,7 +2086,7 @@ class GroupchatControl(ChatControlBase):
item = xml.get_widget('send_file_menuitem')
# add a special img for send file menuitem
path_to_upload_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'upload.png')
path_to_upload_img = gtkgui_helpers.get_icon_path('gajim-upload')
img = gtk.Image()
img.set_from_file(path_to_upload_img)
item.set_image(img)

View File

@ -61,6 +61,26 @@ gtk.glade.textdomain(i18n.APP)
screen_w = gtk.gdk.screen_width()
screen_h = gtk.gdk.screen_height()
gtk_icon_theme = gtk.icon_theme_get_default()
gtk_icon_theme.append_search_path(gajim.ICONS_DIR)
def get_icon_pixmap(icon_name, size=16):
try:
return gtk_icon_theme.load_icon(icon_name, size, 0)
except gobject.GError, e:
log.error('Unable to load icon %s: %s' % (icon_name, str(e)))
def get_icon_path(icon_name, size=16):
try:
icon_info = gtk_icon_theme.lookup_icon(icon_name, size, 0)
if icon_info == None:
log.error('Icon not found: %s' % icon_name)
return ""
else:
return icon_info.get_filename()
except gobject.GError, e:
log.error("Unable to find icon %s: %s" % (icon_name, str(e)))
GLADE_DIR = os.path.join(gajim.DATA_DIR, 'glade')
def get_glade(file_name, root = None):
file_path = os.path.join(GLADE_DIR, file_name)

View File

@ -200,7 +200,7 @@ def get_contact_menu(contact, account, use_multiple_contacts=True,
items_to_hide = []
# add a special img for send file menuitem
path_to_upload_img = os.path.join(gajim.DATA_DIR, 'pixmaps', 'upload.png')
path_to_upload_img = gtkgui_helpers.get_icon_path('gajim-upload')
img = gtk.Image()
img.set_from_file(path_to_upload_img)
send_file_menuitem.set_image(img)