File: weather-icon.c

package info (click to toggle)
xfce4-weather-plugin 0.7.3-3%2Bsqueeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,036 kB
  • ctags: 502
  • sloc: sh: 10,231; ansic: 4,279; makefile: 150
file content (57 lines) | stat: -rw-r--r-- 1,600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*  $Id: weather-icon.c 7550 2009-06-13 07:46:50Z colin $
 *
 *  Copyright (c) 2003-2007 Xfce Development Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib.h>
#include <gtk/gtk.h>

#include "weather-icon.h"



#define DEFAULT_W_THEME "liquid"



GdkPixbuf *
get_icon (const gchar *number,
          gint         size)
{
  GdkPixbuf *image = NULL;
  gchar     *filename;

  filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s" G_DIR_SEPARATOR_S "%s.png",
                              THEMESDIR, DEFAULT_W_THEME, number);

  image = gdk_pixbuf_new_from_file_at_scale (filename, size, size, TRUE, NULL);

  if (G_UNLIKELY (!image)) {
    g_warning ("Unable to open image: %s", filename);
    if (number && strcmp(number, "99")) {
      g_free(filename);
      return get_icon("99", size);
    }
  }
  g_free (filename);

  return image;
}