Commit 5b10d8fe authored by Yann Leboulanger's avatar Yann Leboulanger

base of using icon themes. see #2378

parent aed9690d
......@@ -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
......
SUBDIRS = glade emoticons pixmaps iconsets moods activities
SUBDIRS = glade emoticons pixmaps iconsets moods activities icons
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
......
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
......@@ -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)
......
......@@ -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()))
......
......@@ -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:
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment