aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:07:45 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-31 01:07:45 +0800
commitff811719fa1fd178d9be7edd6b18fb04d0c3a0d3 (patch)
tree0eafaef3d1eace14bb068c3cb0b347c189b5e517 /libempathy-gtk
parent5e818246cfc20394b14756d872145b853a53296c (diff)
downloadgsoc2013-empathy-ff811719fa1fd178d9be7edd6b18fb04d0c3a0d3.tar
gsoc2013-empathy-ff811719fa1fd178d9be7edd6b18fb04d0c3a0d3.tar.gz
gsoc2013-empathy-ff811719fa1fd178d9be7edd6b18fb04d0c3a0d3.tar.bz2
gsoc2013-empathy-ff811719fa1fd178d9be7edd6b18fb04d0c3a0d3.tar.lz
gsoc2013-empathy-ff811719fa1fd178d9be7edd6b18fb04d0c3a0d3.tar.xz
gsoc2013-empathy-ff811719fa1fd178d9be7edd6b18fb04d0c3a0d3.tar.zst
gsoc2013-empathy-ff811719fa1fd178d9be7edd6b18fb04d0c3a0d3.zip
Add a convenience function to avoid hacks when getting the pixbuf from the icon name.
svn path=/trunk/; revision=2288
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c34
-rw-r--r--libempathy-gtk/empathy-ui-utils.h2
2 files changed, 25 insertions, 11 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 7c6166839..1c20c2c9a 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -544,14 +544,12 @@ empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf, gint max_size)
}
GdkPixbuf *
-empathy_pixbuf_from_icon_name (const gchar *icon_name,
- GtkIconSize icon_size)
+empathy_pixbuf_from_icon_name_sized (const gchar *icon_name,
+ gint size)
{
- GtkIconTheme *theme;
- GdkPixbuf *pixbuf = NULL;
- GError *error = NULL;
- gint w, h;
- gint size = 48;
+ GtkIconTheme *theme;
+ GdkPixbuf *pixbuf;
+ GError *error;
if (!icon_name) {
return NULL;
@@ -559,10 +557,6 @@ empathy_pixbuf_from_icon_name (const gchar *icon_name,
theme = gtk_icon_theme_get_default ();
- if (gtk_icon_size_lookup (icon_size, &w, &h)) {
- size = (w + h) / 2;
- }
-
pixbuf = gtk_icon_theme_load_icon (theme,
icon_name,
size,
@@ -576,6 +570,24 @@ empathy_pixbuf_from_icon_name (const gchar *icon_name,
return pixbuf;
}
+GdkPixbuf *
+empathy_pixbuf_from_icon_name (const gchar *icon_name,
+ GtkIconSize icon_size)
+{
+ gint w, h;
+ gint size = 48;
+
+ if (!icon_name) {
+ return NULL;
+ }
+
+ if (gtk_icon_size_lookup (icon_size, &w, &h)) {
+ size = (w + h) / 2;
+ }
+
+ return empathy_pixbuf_from_icon_name_sized (icon_name, size);
+}
+
/* Stolen from GtkSourceView, hence the weird intendation. Please keep it like
* that to make it easier to apply changes from the original code.
*/
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 455ddd7a2..97fb271b3 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -98,6 +98,8 @@ GdkPixbuf * empathy_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbu
gint max_size);
GdkPixbuf * empathy_pixbuf_from_icon_name (const gchar *icon_name,
GtkIconSize icon_size);
+GdkPixbuf * empathy_pixbuf_from_icon_name_sized (const gchar *icon_name,
+ gint size);
/* Text view */
gboolean empathy_text_iter_forward_search (const GtkTextIter*iter,
const gchar *str,