Use macros instead of raw numbers for login type
[rofl0r-ixchat.git] / src / fe-gtk / pixmaps.c
blob3d85c3b021071697000fee58937cf6072dd83f00
1 /* X-Chat
2 * Copyright (C) 1998 Peter Zelezny.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
23 #include "fe-gtk.h"
24 #include "../common/xchat.h"
25 #include "../common/fe.h"
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #include <gdk-pixbuf/gdk-pixdata.h>
29 #include <gtk/gtkstock.h>
31 #include "../pixmaps/inline_pngs.h"
33 GdkPixbuf *pix_xchat;
34 GdkPixbuf *pix_book;
36 GdkPixbuf *pix_purple;
37 GdkPixbuf *pix_red;
38 GdkPixbuf *pix_op;
39 GdkPixbuf *pix_hop;
40 GdkPixbuf *pix_voice;
42 GdkPixbuf *pix_tray_msg;
43 GdkPixbuf *pix_tray_hilight;
44 GdkPixbuf *pix_tray_file;
46 GdkPixbuf *pix_channel;
47 GdkPixbuf *pix_dialog;
48 GdkPixbuf *pix_server;
49 GdkPixbuf *pix_util;
52 static GdkPixmap *
53 pixmap_load_from_file_real (char *file)
55 GdkPixbuf *img;
56 GdkPixmap *pixmap;
58 img = gdk_pixbuf_new_from_file (file, 0);
59 if (!img)
60 return NULL;
61 gdk_pixbuf_render_pixmap_and_mask (img, &pixmap, NULL, 128);
62 gdk_pixbuf_unref (img);
64 return pixmap;
67 GdkPixmap *
68 pixmap_load_from_file (char *filename)
70 char buf[256];
71 GdkPixmap *pix;
73 if (filename[0] == '\0')
74 return NULL;
76 pix = pixmap_load_from_file_real (filename);
77 if (pix == NULL)
79 strcpy (buf, "Cannot open:\n\n");
80 strncpy (buf + 14, filename, sizeof (buf) - 14);
81 buf[sizeof (buf) - 1] = 0;
82 fe_message (buf, FE_MSG_ERROR);
85 return pix;
88 #define LOADPIX(vv,pp,ff) \
89 vv = gdk_pixbuf_new_from_file (XCHATSHAREDIR"/xchat/"ff, 0); \
90 if (!vv) \
91 vv = gdk_pixbuf_new_from_inline (-1, pp, FALSE, 0);
93 #define LOADPIX_DISKONLY(vv,ff) \
94 vv = gdk_pixbuf_new_from_file (XCHATSHAREDIR"/xchat/"ff, 0);
96 #define EXT ".png"
98 void
99 pixmaps_init (void)
101 pix_book = gdk_pixbuf_new_from_inline (-1, bookpng, FALSE, 0);
103 /* used in About window, tray icon and WindowManager icon. */
104 LOADPIX (pix_xchat, xchatpng, "xchat"EXT);
106 /* userlist icons, with inlined defaults */
107 LOADPIX (pix_hop, hoppng, "hop"EXT);
108 LOADPIX (pix_purple, purplepng, "purple"EXT);
109 LOADPIX (pix_red, redpng, "red"EXT);
110 LOADPIX (pix_op, oppng, "op"EXT);
111 LOADPIX (pix_voice, voicepng, "voice"EXT);
113 /* tray icons, with inlined defaults */
114 LOADPIX (pix_tray_msg, traymsgpng, "message"EXT);
115 LOADPIX (pix_tray_hilight, trayhilightpng, "highlight"EXT);
116 LOADPIX (pix_tray_file, trayfilepng, "fileoffer"EXT);
118 /* treeview icons, no defaults, load from disk only */
119 LOADPIX_DISKONLY (pix_channel, "channel"EXT);
120 LOADPIX_DISKONLY (pix_dialog, "dialog"EXT);
121 LOADPIX_DISKONLY (pix_server, "server"EXT);
122 LOADPIX_DISKONLY (pix_util, "util"EXT);