This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

GNOME Goal: Install theme-friendly icons

Many applications install their icon by putting it into $datadir/pixmaps and hardcoding the URL to it in their application. The problem with this is that icon themes cannot override the icon for your application. To fix this, one should follow the icon theme specification. This memo summarizes what you need to do in your GNOME application to make all theme designers happier.

First you should prepare your icon. If your application icon is too old and doesn't look good, consider asking somebody on Planet or IRC to draw a new one for you. It is preferred to follow the Tango guidelines when designing new icons. You should then prepare a 48x48 PNG version of the icon, and preferably an SVG version too. It's recommended to ship 16x16, 22x22, 24x24 (for gnome-panel), 32x32 and 48x48 SVG.

Build system

In your Makefile.am, this is how you install it (say your application name is gurilla):

icondir = $(datadir)/icons/hicolor/48x48/apps
icon_DATA = gurilla.png
svgicondir = $(datadir)/icons/hicolor/scalable/apps
svgicon_DATA = gurilla.svg
gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
install-data-hook: update-icon-cache
uninstall-hook: update-icon-cache
update-icon-cache:
        @-if test -z "$(DESTDIR)"; then \
                echo "Updating Gtk icon cache."; \
                $(gtk_update_icon_cache); \
        else \
                echo "*** Icon cache not updated.  After (un)install, run this:"; \
                echo "***   $(gtk_update_icon_cache)"; \
        fi
EXTRA_DIST = \
        $(icon_DATA) \
        $(svgicon_DATA)

(If you copy and paste that snippet, note that the indentation in the update-icon-cache target should be with tabs instead of spaces.)

Application code

The preferred way to refer to icons is by their name. You should set a default icon name in your main function before creating any windows, like after setting application name for example:

  g_set_application_name (_("Gurilla"));
  gtk_window_set_default_icon_name ("gurilla");

That is all you need to do for most applications. It will set the icon for any window created in your application (that does not set its own icon.)

If your application also exposes a library with window widgets that other applications may use, and you want to set an icon on those windows too, you can do that by setting the icon for the window in its constructor. But before doing that make sure it is really what you want. For example, you don't want the Gtk+ icon on a font dialog. Anyhow, here it is:

static void
gurilla_window_init (GurillaWindow *guw)
{
  ...
  gtk_window_set_title (GTK_WINDOW (guw), _("Gurilla Dialog"));
  gtk_window_set_icon_name (GTK_WINDOW (guw), "gurilla");
}

Last, you should set the icon name in your about dialog:

  gtk_show_about_dialog (GTK_WINDOW (guw),
                         ...
                         "logo-icon-name", "gurilla",
                         ...
                         NULL);

Desktop file

The icon name in the .desktop file should not have an extension, for obvious reasons.

Status of this goal

Completed.

When starting to work on one module, you can also put your name in the status so that other people don't duplicate the work you're doing.

State

Markup

todo

<: #ff8080> todo

patch

<: #ffc849> [[GnomeBug:xxxxx|patch]]

done

<: #80ff80> [[GnomeBug:xxxxx|done]]

not needed

<: #80ff80> not needed

Above are the states and corresponding markup to update the modules state table below.

Module

Status

Desktop

alacarte

done

bug-buddy

done

cheese

not needed

control-center

done

dasher

done

deskbar-applet

done

eel

not needed

ekiga

done

eog

done

epiphany

not needed

evince

not needed

evolution-data-server

not needed

evolution

done

evolution-exchange

not needed

evolution-webcal

not needed

fast-user-switch-applet

not needed

file-roller

done

gcalctool

not needed

gconf-editor

done

gdm

done

gedit

not needed

gnome-applets

done

gnome-backgrounds

not needed

gnome-desktop

not needed

gnome-doc-utils

not needed

gnome-games

done

gnome-icon-theme

not needed

gnome-keyring

not needed

gnome-netstatus

done

gnome-nettool

done

gnome-mag

done

gnome-media

done

gnome-menus

not needed

gnome-panel

done

gnome-power-manager

done

gnome-python-desktop

not needed

gnome-screensaver

not needed

gnome-session

not needed

gnome-settings-daemon

not needed

gnome-speech

not needed

gnome-system-monitor

not needed

gnome-system-tools

done

gnome-terminal

done

gnome-themes

not needed

gnome-user-docs

not needed

gnome-utils

done

gnome-volume-manager

done

gok

done

gstreamer

not needed

gst-plugins

not needed

gtk-engines

not needed

gtkhtml

not needed

gtksourceview

not needed

gucharmap

done

gvfs

not needed

libgail-gnome

not needed

libgnomekbd

done

libgtop

not needed

libgweather

not needed

liboobs

not needed

librsvg

not needed

libsoup

not needed

libwnck

not needed

metacity

not needed

mousetweaks

not needed

nautilus

not needed

nautilus-cd-burner

done

orca

not needed

pygtksourceview

not needed

seahorse

done

sound-juicer

not needed

swfdec-gnome

not needed

tomboy

not needed

totem

done

totem-pl-parser

not needed

vinagre

not needed

vino

done

vte

not needed

yelp

not needed

zenity

not needed

Desktop (to be deprecated)

gnome-keyring-manager

not needed

libgnomeprint

not needed

libgnomeprintui

not needed

Platform

GConf

not needed

at-spi

not needed

atk

not needed

gail

not needed

glib

not needed

gnome-mime-data

not needed

gnome-vfs

not needed

gtk+

not needed

gtk-doc

not needed

intltool

not needed

libglade

not needed

libxml2

not needed

libxslt

not needed

pango

not needed

pkgconfig

not needed

Platform (to be deprecated)

ORBit2

not needed

audiofile

not needed

esound

not needed

libIDL

not needed

libart_lgpl

not needed

libbonobo

not needed

libbonoboui

not needed

libgnome

not needed

libgnomecanvas

not needed

libgnomeui

not needed

Admin

pessulus

not needed

sabayon

done

Development Tools

accerciser

not needed

anjuta

done

devhelp

not needed

gdl

not needed

glade-3

done

gnome-build

not needed

gnome-devel-docs

not needed

Bindings (C++)

glibmm

not needed

gtkmm

not needed

libglademm

not needed

gconfmm

not needed

libgnomecanvasmm

not needed

libgnome-vfsmm

not needed

libgnomemm

not needed

libgnomeuimm

not needed

libxml++

not needed

Bindings (java)

glib-java (jg-common)

not needed

libgtk-java

not needed

libgnome-java

not needed

libgconf-java

not needed

libglade-java

not needed

Bindings (perl)

Glib

not needed

Gtk2

not needed

Gtk2-GladeXML

not needed

Gnome2-GConf

not needed

Gnome2-Canvas

not needed

Gnome2-VFS

not needed

Gnome2

not needed

Bindings (python)

pygobject

not needed

pygtk

not needed

Gnome-Python

not needed

Other

gnome-blog

done

gossip

done

nautilus-actions

done

rhythmbox

done

startup-notification

not needed

xchat-gnome

done

smuxi

done

gthumb

done

this goal in other languages

AppIconZhCN for Simplified Chinese (简体中文)


2024-10-23 11:17