Statistics
| Revision:

root / src / stock_pixmap.c @ 1

History | View | Annotate | Download (5.7 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

    
20
#include <glib.h>
21
#include <gtk/gtkwidget.h>
22
#include <gtk/gtkpixmap.h>
23

    
24
#include "stock_pixmap.h"
25
#include "gtkutils.h"
26

    
27
#include "pixmaps/address.xpm"
28
#include "pixmaps/book.xpm"
29
#include "pixmaps/category.xpm"
30
#include "pixmaps/checkbox_off.xpm"
31
#include "pixmaps/checkbox_on.xpm"
32
#include "pixmaps/clip.xpm"
33
#include "pixmaps/complete.xpm"
34
#include "pixmaps/continue.xpm"
35
#include "pixmaps/deleted.xpm"
36
#include "pixmaps/dir-close.xpm"
37
#include "pixmaps/dir-open.xpm"
38
#include "pixmaps/dir-noselect.xpm"
39
#include "pixmaps/error.xpm"
40
#include "pixmaps/forwarded.xpm"
41
#include "pixmaps/group.xpm"
42
#include "pixmaps/inbox.xpm"
43
#include "pixmaps/interface.xpm"
44
#include "pixmaps/jpilot.xpm"
45
#include "pixmaps/ldap.xpm"
46
#include "pixmaps/linewrap.xpm"
47
#include "pixmaps/mark.xpm"
48
#include "pixmaps/new.xpm"
49
#include "pixmaps/outbox.xpm"
50
#include "pixmaps/replied.xpm"
51
#include "pixmaps/stock_close.xpm"
52
#include "pixmaps/stock_down_arrow.xpm"
53
#include "pixmaps/stock_exec.xpm"
54
#include "pixmaps/stock_mail.xpm"
55
#include "pixmaps/stock_mail_attach.xpm"
56
#include "pixmaps/stock_mail_compose.xpm"
57
#include "pixmaps/stock_mail_forward.xpm"
58
#include "pixmaps/stock_mail_receive.xpm"
59
#include "pixmaps/stock_mail_receive_all.xpm"
60
#include "pixmaps/stock_mail_reply.xpm"
61
#include "pixmaps/stock_mail_reply_to_all.xpm"
62
#include "pixmaps/stock_mail_send.xpm"
63
#include "pixmaps/stock_mail_send_queue.xpm"
64
#include "pixmaps/stock_paste.xpm"
65
#include "pixmaps/stock_preferences.xpm"
66
#include "pixmaps/stock_properties.xpm"
67
#include "pixmaps/sylpheed-logo.xpm"
68
#include "pixmaps/tb_address_book.xpm"
69
#include "pixmaps/trash.xpm"
70
#include "pixmaps/unread.xpm"
71
#include "pixmaps/vcard.xpm"
72
#include "pixmaps/online.xpm"
73
#include "pixmaps/offline.xpm"
74
#include "pixmaps/stock_dialog_info_48.xpm"
75
#include "pixmaps/stock_dialog_question_48.xpm"
76
#include "pixmaps/stock_dialog_warning_48.xpm"
77
#include "pixmaps/stock_dialog_error_48.xpm"
78
#include "pixmaps/stock_add_16.xpm"
79
#include "pixmaps/stock_remove_16.xpm"
80
#include "pixmaps/mail.xpm"
81

    
82
typedef struct _StockPixmapData        StockPixmapData;
83

    
84
struct _StockPixmapData
85
{
86
        gchar **data;
87
        GdkPixmap *pixmap;
88
        GdkBitmap *mask;
89
};
90

    
91
static StockPixmapData pixmaps[] =
92
{
93
        {address_xpm                        , NULL, NULL},
94
        {book_xpm                        , NULL, NULL},
95
        {category_xpm                        , NULL, NULL},
96
        {checkbox_off_xpm                , NULL, NULL},
97
        {checkbox_on_xpm                , NULL, NULL},
98
        {clip_xpm                        , NULL, NULL},
99
        {complete_xpm                        , NULL, NULL},
100
        {continue_xpm                        , NULL, NULL},
101
        {deleted_xpm                        , NULL, NULL},
102
        {dir_close_xpm                        , NULL, NULL},
103
        {dir_open_xpm                        , NULL, NULL},
104
        {dir_noselect_xpm                , NULL, NULL},
105
        {error_xpm                        , NULL, NULL},
106
        {forwarded_xpm                        , NULL, NULL},
107
        {group_xpm                        , NULL, NULL},
108
        {inbox_xpm                        , NULL, NULL},
109
        {interface_xpm                        , NULL, NULL},
110
        {jpilot_xpm                        , NULL, NULL},
111
        {ldap_xpm                        , NULL, NULL},
112
        {linewrap_xpm                        , NULL, NULL},
113
        {mark_xpm                        , NULL, NULL},
114
        {new_xpm                        , NULL, NULL},
115
        {outbox_xpm                        , NULL, NULL},
116
        {replied_xpm                        , NULL, NULL},
117
        {stock_close_xpm                , NULL, NULL},
118
        {stock_down_arrow_xpm                , NULL, NULL},
119
        {stock_exec_xpm                        , NULL, NULL},
120
        {stock_mail_xpm                        , NULL, NULL},
121
        {stock_mail_attach_xpm                , NULL, NULL},
122
        {stock_mail_compose_xpm                , NULL, NULL},
123
        {stock_mail_forward_xpm                , NULL, NULL},
124
        {stock_mail_receive_xpm                , NULL, NULL},
125
        {stock_mail_receive_all_xpm        , NULL, NULL},
126
        {stock_mail_reply_xpm                , NULL, NULL},
127
        {stock_mail_reply_to_all_xpm        , NULL, NULL},
128
        {stock_mail_send_xpm                , NULL, NULL},
129
        {stock_mail_send_queue_xpm        , NULL, NULL},
130
        {stock_paste_xpm                , NULL, NULL},
131
        {stock_preferences_xpm                , NULL, NULL},
132
        {stock_properties_xpm                , NULL, NULL},
133
        {sylpheed_logo_xpm                , NULL, NULL},
134
        {tb_address_book_xpm                , NULL, NULL},
135
        {trash_xpm                        , NULL, NULL},
136
        {unread_xpm                        , NULL, NULL},
137
        {vcard_xpm                        , NULL, NULL},
138
        {online_xpm                        , NULL, NULL},
139
        {offline_xpm                        , NULL, NULL},
140
        {stock_dialog_info_48_xpm        , NULL, NULL},
141
        {stock_dialog_question_48_xpm        , NULL, NULL},
142
        {stock_dialog_warning_48_xpm        , NULL, NULL},
143
        {stock_dialog_error_48_xpm        , NULL, NULL},
144
        {stock_add_16_xpm                , NULL, NULL},
145
        {stock_remove_16_xpm                , NULL, NULL},
146
        {mail_xpm                        , NULL, NULL},
147
};
148

    
149
/* return newly constructed GtkPixmap from GdkPixmap */
150
GtkWidget *stock_pixmap_widget(GtkWidget *window, StockPixmap icon)
151
{
152
        GdkPixmap *pixmap;
153
        GdkBitmap *mask;
154

    
155
        g_return_val_if_fail(window != NULL, NULL);
156
        g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
157

    
158
        stock_pixmap_gdk(window, icon, &pixmap, &mask);
159
        return gtk_pixmap_new(pixmap, mask);
160
}
161

    
162
/* create GdkPixmap if it has not created yet */
163
gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
164
                      GdkPixmap **pixmap, GdkBitmap **mask)
165
{
166
        StockPixmapData *pix_d;
167

    
168
        if (pixmap) *pixmap = NULL;
169
        if (mask)   *mask   = NULL;
170

    
171
        g_return_val_if_fail(window != NULL, -1);
172
        g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1);
173

    
174
        pix_d = &pixmaps[icon];
175

    
176
        if (!pix_d->pixmap) {
177
                PIXMAP_CREATE(window, pix_d->pixmap, pix_d->mask,
178
                              pix_d->data);
179
        }
180

    
181
        if (pixmap) *pixmap = pix_d->pixmap;
182
        if (mask)   *mask   = pix_d->mask;
183

    
184
        return 0;
185
}