root / src / headerview.c @ 2732
History | View | Annotate | Download (10.8 kB)
| 1 | 1 | hiro | /*
|
|---|---|---|---|
| 2 | 1 | hiro | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | 1296 | hiro | * Copyright (C) 1999-2006 Hiroyuki Yamamoto |
| 4 | 1 | hiro | * |
| 5 | 1 | hiro | * This program is free software; you can redistribute it and/or modify |
| 6 | 1 | hiro | * it under the terms of the GNU General Public License as published by |
| 7 | 1 | hiro | * the Free Software Foundation; either version 2 of the License, or |
| 8 | 1 | hiro | * (at your option) any later version. |
| 9 | 1 | hiro | * |
| 10 | 1 | hiro | * This program is distributed in the hope that it will be useful, |
| 11 | 1 | hiro | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | 1 | hiro | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | 1 | hiro | * GNU General Public License for more details. |
| 14 | 1 | hiro | * |
| 15 | 1 | hiro | * You should have received a copy of the GNU General Public License |
| 16 | 1 | hiro | * along with this program; if not, write to the Free Software |
| 17 | 1 | hiro | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | 1 | hiro | */ |
| 19 | 1 | hiro | |
| 20 | 1 | hiro | #ifdef HAVE_CONFIG_H
|
| 21 | 1 | hiro | # include "config.h" |
| 22 | 1 | hiro | #endif
|
| 23 | 1 | hiro | |
| 24 | 1 | hiro | #include "defs.h" |
| 25 | 1 | hiro | |
| 26 | 1 | hiro | #include <glib.h> |
| 27 | 92 | hiro | #include <glib/gi18n.h> |
| 28 | 1 | hiro | #include <gtk/gtkwidget.h> |
| 29 | 1 | hiro | #include <gtk/gtkstyle.h> |
| 30 | 1 | hiro | #include <gtk/gtkscrolledwindow.h> |
| 31 | 1 | hiro | #include <gtk/gtkhbox.h> |
| 32 | 1 | hiro | #include <gtk/gtkvbox.h> |
| 33 | 1 | hiro | #include <gtk/gtklabel.h> |
| 34 | 1 | hiro | #include <gtk/gtkpixmap.h> |
| 35 | 256 | hiro | #include <gtk/gtkimage.h> |
| 36 | 1 | hiro | #include <stdio.h> |
| 37 | 1 | hiro | #include <string.h> |
| 38 | 1 | hiro | #include <time.h> |
| 39 | 1 | hiro | |
| 40 | 1 | hiro | #if HAVE_LIBCOMPFACE
|
| 41 | 1 | hiro | # include <compface.h> |
| 42 | 1 | hiro | #endif
|
| 43 | 1 | hiro | |
| 44 | 1 | hiro | #include "main.h" |
| 45 | 1 | hiro | #include "headerview.h" |
| 46 | 1 | hiro | #include "prefs_common.h" |
| 47 | 1 | hiro | #include "codeconv.h" |
| 48 | 1 | hiro | #include "gtkutils.h" |
| 49 | 1 | hiro | #include "utils.h" |
| 50 | 1 | hiro | |
| 51 | 1 | hiro | #define TR(str) (prefs_common.trans_hdr ? gettext(str) : str)
|
| 52 | 1 | hiro | |
| 53 | 1 | hiro | #if 0
|
| 54 | 1 | hiro | _("From:");
|
| 55 | 1 | hiro | _("To:");
|
| 56 | 1296 | hiro | _("Cc:");
|
| 57 | 1 | hiro | _("Newsgroups:");
|
| 58 | 1 | hiro | _("Subject:");
|
| 59 | 1 | hiro | #endif |
| 60 | 1 | hiro | |
| 61 | 1 | hiro | #if HAVE_LIBCOMPFACE
|
| 62 | 1 | hiro | #define XPM_XFACE_HEIGHT (HEIGHT + 3) /* 3 = 1 header + 2 colors */ |
| 63 | 1 | hiro | |
| 64 | 1 | hiro | static gchar *xpm_xface[XPM_XFACE_HEIGHT];
|
| 65 | 1 | hiro | |
| 66 | 1 | hiro | static void headerview_show_xface (HeaderView *headerview, |
| 67 | 1 | hiro | MsgInfo *msginfo); |
| 68 | 1 | hiro | static gint create_xpm_from_xface (gchar *xpm[],
|
| 69 | 1 | hiro | const gchar *xface);
|
| 70 | 1 | hiro | #endif
|
| 71 | 1 | hiro | |
| 72 | 1 | hiro | HeaderView *headerview_create(void)
|
| 73 | 1 | hiro | {
|
| 74 | 1 | hiro | HeaderView *headerview; |
| 75 | 1 | hiro | GtkWidget *hbox; |
| 76 | 1 | hiro | GtkWidget *vbox; |
| 77 | 1 | hiro | GtkWidget *hbox1; |
| 78 | 1 | hiro | GtkWidget *hbox2; |
| 79 | 1 | hiro | GtkWidget *from_header_label; |
| 80 | 1 | hiro | GtkWidget *from_body_label; |
| 81 | 1 | hiro | GtkWidget *to_header_label; |
| 82 | 1 | hiro | GtkWidget *to_body_label; |
| 83 | 1296 | hiro | GtkWidget *cc_header_label; |
| 84 | 1296 | hiro | GtkWidget *cc_body_label; |
| 85 | 1 | hiro | GtkWidget *ng_header_label; |
| 86 | 1 | hiro | GtkWidget *ng_body_label; |
| 87 | 1 | hiro | GtkWidget *subject_header_label; |
| 88 | 1 | hiro | GtkWidget *subject_body_label; |
| 89 | 1 | hiro | |
| 90 | 1 | hiro | debug_print(_("Creating header view...\n"));
|
| 91 | 1 | hiro | headerview = g_new0(HeaderView, 1);
|
| 92 | 1 | hiro | |
| 93 | 1 | hiro | hbox = gtk_hbox_new(FALSE, 0);
|
| 94 | 1 | hiro | gtk_container_set_border_width(GTK_CONTAINER(hbox), 2);
|
| 95 | 446 | hiro | vbox = gtk_vbox_new(FALSE, 2);
|
| 96 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
|
| 97 | 1 | hiro | |
| 98 | 1 | hiro | hbox1 = gtk_hbox_new(FALSE, 4);
|
| 99 | 1 | hiro | gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 0);
|
| 100 | 1 | hiro | hbox2 = gtk_hbox_new(FALSE, 4);
|
| 101 | 1 | hiro | gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
|
| 102 | 1 | hiro | |
| 103 | 1 | hiro | from_header_label = gtk_label_new(TR("From:"));
|
| 104 | 1 | hiro | from_body_label = gtk_label_new("");
|
| 105 | 1 | hiro | to_header_label = gtk_label_new(TR("To:"));
|
| 106 | 1 | hiro | to_body_label = gtk_label_new("");
|
| 107 | 1296 | hiro | cc_header_label = gtk_label_new(TR("Cc:"));
|
| 108 | 1296 | hiro | cc_body_label = gtk_label_new("");
|
| 109 | 1 | hiro | ng_header_label = gtk_label_new(TR("Newsgroups:"));
|
| 110 | 1 | hiro | ng_body_label = gtk_label_new("");
|
| 111 | 1 | hiro | subject_header_label = gtk_label_new(TR("Subject:"));
|
| 112 | 1 | hiro | subject_body_label = gtk_label_new("");
|
| 113 | 1 | hiro | |
| 114 | 1 | hiro | gtk_label_set_selectable(GTK_LABEL(from_body_label), TRUE); |
| 115 | 1 | hiro | gtk_label_set_selectable(GTK_LABEL(to_body_label), TRUE); |
| 116 | 1296 | hiro | gtk_label_set_selectable(GTK_LABEL(cc_body_label), TRUE); |
| 117 | 1 | hiro | gtk_label_set_selectable(GTK_LABEL(ng_body_label), TRUE); |
| 118 | 1 | hiro | gtk_label_set_selectable(GTK_LABEL(subject_body_label), TRUE); |
| 119 | 1 | hiro | |
| 120 | 298 | hiro | GTK_WIDGET_UNSET_FLAGS(from_body_label, GTK_CAN_FOCUS); |
| 121 | 298 | hiro | GTK_WIDGET_UNSET_FLAGS(to_body_label, GTK_CAN_FOCUS); |
| 122 | 1296 | hiro | GTK_WIDGET_UNSET_FLAGS(cc_body_label, GTK_CAN_FOCUS); |
| 123 | 298 | hiro | GTK_WIDGET_UNSET_FLAGS(ng_body_label, GTK_CAN_FOCUS); |
| 124 | 298 | hiro | GTK_WIDGET_UNSET_FLAGS(subject_body_label, GTK_CAN_FOCUS); |
| 125 | 298 | hiro | |
| 126 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), from_header_label, FALSE, FALSE, 0);
|
| 127 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), from_body_label, FALSE, FALSE, 0);
|
| 128 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), to_header_label, FALSE, FALSE, 0);
|
| 129 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), to_body_label, FALSE, FALSE, 0);
|
| 130 | 1296 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), cc_header_label, FALSE, FALSE, 0);
|
| 131 | 1296 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), cc_body_label, FALSE, FALSE, 0);
|
| 132 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), ng_header_label, FALSE, FALSE, 0);
|
| 133 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox1), ng_body_label, FALSE, FALSE, 0);
|
| 134 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox2), subject_header_label, FALSE, FALSE, 0);
|
| 135 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox2), subject_body_label, FALSE, FALSE, 0);
|
| 136 | 1 | hiro | |
| 137 | 1 | hiro | headerview->hbox = hbox; |
| 138 | 1 | hiro | headerview->from_header_label = from_header_label; |
| 139 | 1 | hiro | headerview->from_body_label = from_body_label; |
| 140 | 1 | hiro | headerview->to_header_label = to_header_label; |
| 141 | 1 | hiro | headerview->to_body_label = to_body_label; |
| 142 | 1296 | hiro | headerview->cc_header_label = cc_header_label; |
| 143 | 1296 | hiro | headerview->cc_body_label = cc_body_label; |
| 144 | 1 | hiro | headerview->ng_header_label = ng_header_label; |
| 145 | 1 | hiro | headerview->ng_body_label = ng_body_label; |
| 146 | 1 | hiro | headerview->subject_header_label = subject_header_label; |
| 147 | 1 | hiro | headerview->subject_body_label = subject_body_label; |
| 148 | 1 | hiro | headerview->image = NULL;
|
| 149 | 1 | hiro | |
| 150 | 1 | hiro | gtk_widget_show_all(hbox); |
| 151 | 1 | hiro | |
| 152 | 1 | hiro | return headerview;
|
| 153 | 1 | hiro | } |
| 154 | 1 | hiro | |
| 155 | 1 | hiro | void headerview_init(HeaderView *headerview)
|
| 156 | 1 | hiro | {
|
| 157 | 1 | hiro | static PangoFontDescription *boldfont = NULL; |
| 158 | 1222 | hiro | #ifdef G_OS_WIN32
|
| 159 | 1222 | hiro | GtkStyle *style; |
| 160 | 1222 | hiro | #endif
|
| 161 | 1 | hiro | |
| 162 | 39 | hiro | if (!boldfont) {
|
| 163 | 39 | hiro | boldfont = pango_font_description_new(); |
| 164 | 39 | hiro | pango_font_description_set_weight(boldfont, PANGO_WEIGHT_BOLD); |
| 165 | 39 | hiro | } |
| 166 | 1 | hiro | |
| 167 | 39 | hiro | if (boldfont) {
|
| 168 | 39 | hiro | gtk_widget_modify_font(headerview->from_header_label, boldfont); |
| 169 | 39 | hiro | gtk_widget_modify_font(headerview->to_header_label, boldfont); |
| 170 | 1296 | hiro | gtk_widget_modify_font(headerview->cc_header_label, boldfont); |
| 171 | 39 | hiro | gtk_widget_modify_font(headerview->ng_header_label, boldfont); |
| 172 | 39 | hiro | gtk_widget_modify_font(headerview->subject_header_label, boldfont); |
| 173 | 39 | hiro | } |
| 174 | 1 | hiro | |
| 175 | 1222 | hiro | #ifdef G_OS_WIN32
|
| 176 | 1222 | hiro | #define SET_LABEL_STYLE(label) \
|
| 177 | 1222 | hiro | style = gtk_widget_get_style(label); \ |
| 178 | 1222 | hiro | gtk_widget_modify_base(label, GTK_STATE_ACTIVE, \ |
| 179 | 1222 | hiro | &style->base[GTK_STATE_SELECTED]); \ |
| 180 | 1222 | hiro | gtk_widget_modify_text(label, GTK_STATE_ACTIVE, \ |
| 181 | 1222 | hiro | &style->text[GTK_STATE_SELECTED]); |
| 182 | 1222 | hiro | |
| 183 | 1222 | hiro | SET_LABEL_STYLE(headerview->from_body_label); |
| 184 | 1222 | hiro | SET_LABEL_STYLE(headerview->to_body_label); |
| 185 | 1296 | hiro | SET_LABEL_STYLE(headerview->cc_body_label); |
| 186 | 1222 | hiro | SET_LABEL_STYLE(headerview->ng_body_label); |
| 187 | 1222 | hiro | SET_LABEL_STYLE(headerview->subject_body_label); |
| 188 | 1222 | hiro | |
| 189 | 1222 | hiro | #undef SET_LABEL_STYLE
|
| 190 | 1222 | hiro | #endif
|
| 191 | 1222 | hiro | |
| 192 | 1 | hiro | headerview_clear(headerview); |
| 193 | 1 | hiro | headerview_set_visibility(headerview, prefs_common.display_header_pane); |
| 194 | 1 | hiro | |
| 195 | 1 | hiro | #if HAVE_LIBCOMPFACE
|
| 196 | 1 | hiro | {
|
| 197 | 1 | hiro | gint i; |
| 198 | 1 | hiro | |
| 199 | 1 | hiro | for (i = 0; i < XPM_XFACE_HEIGHT; i++) { |
| 200 | 1 | hiro | xpm_xface[i] = g_malloc(WIDTH + 1);
|
| 201 | 1 | hiro | *xpm_xface[i] = '\0';
|
| 202 | 1 | hiro | } |
| 203 | 1 | hiro | } |
| 204 | 1 | hiro | #endif
|
| 205 | 1 | hiro | } |
| 206 | 1 | hiro | |
| 207 | 1 | hiro | void headerview_show(HeaderView *headerview, MsgInfo *msginfo)
|
| 208 | 1 | hiro | {
|
| 209 | 1 | hiro | headerview_clear(headerview); |
| 210 | 1 | hiro | |
| 211 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->from_body_label), |
| 212 | 1 | hiro | msginfo->from ? msginfo->from : _("(No From)"));
|
| 213 | 1 | hiro | if (msginfo->to) {
|
| 214 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->to_body_label), |
| 215 | 1 | hiro | msginfo->to); |
| 216 | 1 | hiro | gtk_widget_show(headerview->to_header_label); |
| 217 | 1 | hiro | gtk_widget_show(headerview->to_body_label); |
| 218 | 1 | hiro | } |
| 219 | 1296 | hiro | if (msginfo->cc) {
|
| 220 | 1296 | hiro | gtk_label_set_text(GTK_LABEL(headerview->cc_body_label), |
| 221 | 1296 | hiro | msginfo->cc); |
| 222 | 1296 | hiro | gtk_widget_show(headerview->cc_header_label); |
| 223 | 1296 | hiro | gtk_widget_show(headerview->cc_body_label); |
| 224 | 1296 | hiro | } |
| 225 | 1 | hiro | if (msginfo->newsgroups) {
|
| 226 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->ng_body_label), |
| 227 | 1 | hiro | msginfo->newsgroups); |
| 228 | 1 | hiro | gtk_widget_show(headerview->ng_header_label); |
| 229 | 1 | hiro | gtk_widget_show(headerview->ng_body_label); |
| 230 | 1 | hiro | } |
| 231 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->subject_body_label), |
| 232 | 1 | hiro | msginfo->subject ? msginfo->subject |
| 233 | 1 | hiro | : _("(No Subject)"));
|
| 234 | 1 | hiro | |
| 235 | 1 | hiro | #if HAVE_LIBCOMPFACE
|
| 236 | 1 | hiro | headerview_show_xface(headerview, msginfo); |
| 237 | 1 | hiro | #endif
|
| 238 | 1 | hiro | } |
| 239 | 1 | hiro | |
| 240 | 1 | hiro | #if HAVE_LIBCOMPFACE
|
| 241 | 1 | hiro | static void headerview_show_xface(HeaderView *headerview, MsgInfo *msginfo) |
| 242 | 1 | hiro | {
|
| 243 | 1 | hiro | gchar xface[2048];
|
| 244 | 1 | hiro | GdkPixmap *pixmap; |
| 245 | 1 | hiro | GdkBitmap *mask; |
| 246 | 1 | hiro | GtkWidget *hbox = headerview->hbox; |
| 247 | 1 | hiro | |
| 248 | 1 | hiro | if (!msginfo->xface || strlen(msginfo->xface) < 5) { |
| 249 | 1 | hiro | if (headerview->image &&
|
| 250 | 1 | hiro | GTK_WIDGET_VISIBLE(headerview->image)) {
|
| 251 | 1 | hiro | gtk_widget_hide(headerview->image); |
| 252 | 1 | hiro | gtk_widget_queue_resize(hbox); |
| 253 | 1 | hiro | } |
| 254 | 1 | hiro | return;
|
| 255 | 1 | hiro | } |
| 256 | 1 | hiro | if (!GTK_WIDGET_VISIBLE(headerview->hbox)) return; |
| 257 | 1 | hiro | |
| 258 | 1 | hiro | strncpy(xface, msginfo->xface, sizeof(xface));
|
| 259 | 1 | hiro | |
| 260 | 1 | hiro | if (uncompface(xface) < 0) { |
| 261 | 1 | hiro | g_warning("uncompface failed\n");
|
| 262 | 1 | hiro | if (headerview->image)
|
| 263 | 1 | hiro | gtk_widget_hide(headerview->image); |
| 264 | 1 | hiro | return;
|
| 265 | 1 | hiro | } |
| 266 | 1 | hiro | |
| 267 | 1 | hiro | create_xpm_from_xface(xpm_xface, xface); |
| 268 | 1 | hiro | |
| 269 | 1 | hiro | pixmap = gdk_pixmap_create_from_xpm_d |
| 270 | 1 | hiro | (hbox->window, &mask, &hbox->style->white, xpm_xface); |
| 271 | 1 | hiro | |
| 272 | 1 | hiro | if (!headerview->image) {
|
| 273 | 1 | hiro | GtkWidget *image; |
| 274 | 1 | hiro | |
| 275 | 1 | hiro | image = gtk_image_new_from_pixmap(pixmap, mask); |
| 276 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
|
| 277 | 1 | hiro | gtk_widget_show(image); |
| 278 | 1 | hiro | headerview->image = image; |
| 279 | 1 | hiro | } else {
|
| 280 | 1 | hiro | gtk_image_set_from_pixmap(GTK_IMAGE(headerview->image), |
| 281 | 1 | hiro | pixmap, mask); |
| 282 | 1 | hiro | gtk_widget_show(headerview->image); |
| 283 | 1 | hiro | } |
| 284 | 1 | hiro | |
| 285 | 1 | hiro | gdk_pixmap_unref(pixmap); |
| 286 | 1 | hiro | } |
| 287 | 1 | hiro | #endif
|
| 288 | 1 | hiro | |
| 289 | 1 | hiro | void headerview_clear(HeaderView *headerview)
|
| 290 | 1 | hiro | {
|
| 291 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->from_body_label), "");
|
| 292 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->to_body_label), "");
|
| 293 | 1296 | hiro | gtk_label_set_text(GTK_LABEL(headerview->cc_body_label), "");
|
| 294 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->ng_body_label), "");
|
| 295 | 1 | hiro | gtk_label_set_text(GTK_LABEL(headerview->subject_body_label), "");
|
| 296 | 1 | hiro | gtk_widget_hide(headerview->to_header_label); |
| 297 | 1 | hiro | gtk_widget_hide(headerview->to_body_label); |
| 298 | 1296 | hiro | gtk_widget_hide(headerview->cc_header_label); |
| 299 | 1296 | hiro | gtk_widget_hide(headerview->cc_body_label); |
| 300 | 1 | hiro | gtk_widget_hide(headerview->ng_header_label); |
| 301 | 1 | hiro | gtk_widget_hide(headerview->ng_body_label); |
| 302 | 1 | hiro | |
| 303 | 1 | hiro | if (headerview->image && GTK_WIDGET_VISIBLE(headerview->image)) {
|
| 304 | 1 | hiro | gtk_widget_hide(headerview->image); |
| 305 | 1 | hiro | gtk_widget_queue_resize(headerview->hbox); |
| 306 | 1 | hiro | } |
| 307 | 1 | hiro | } |
| 308 | 1 | hiro | |
| 309 | 1 | hiro | void headerview_set_visibility(HeaderView *headerview, gboolean visibility)
|
| 310 | 1 | hiro | {
|
| 311 | 1 | hiro | if (visibility)
|
| 312 | 1 | hiro | gtk_widget_show(headerview->hbox); |
| 313 | 1 | hiro | else
|
| 314 | 1 | hiro | gtk_widget_hide(headerview->hbox); |
| 315 | 1 | hiro | } |
| 316 | 1 | hiro | |
| 317 | 1 | hiro | void headerview_destroy(HeaderView *headerview)
|
| 318 | 1 | hiro | {
|
| 319 | 1 | hiro | g_free(headerview); |
| 320 | 1 | hiro | } |
| 321 | 1 | hiro | |
| 322 | 1 | hiro | #if HAVE_LIBCOMPFACE
|
| 323 | 1 | hiro | static gint create_xpm_from_xface(gchar *xpm[], const gchar *xface) |
| 324 | 1 | hiro | {
|
| 325 | 1 | hiro | static gchar *bit_pattern[] = {
|
| 326 | 1 | hiro | "....",
|
| 327 | 1 | hiro | "...#",
|
| 328 | 1 | hiro | "..#.",
|
| 329 | 1 | hiro | "..##",
|
| 330 | 1 | hiro | ".#..",
|
| 331 | 1 | hiro | ".#.#",
|
| 332 | 1 | hiro | ".##.",
|
| 333 | 1 | hiro | ".###",
|
| 334 | 1 | hiro | "#...",
|
| 335 | 1 | hiro | "#..#",
|
| 336 | 1 | hiro | "#.#.",
|
| 337 | 1 | hiro | "#.##",
|
| 338 | 1 | hiro | "##..",
|
| 339 | 1 | hiro | "##.#",
|
| 340 | 1 | hiro | "###.",
|
| 341 | 1 | hiro | "####"
|
| 342 | 1 | hiro | }; |
| 343 | 1 | hiro | |
| 344 | 1 | hiro | static gchar *xface_header = "48 48 2 1"; |
| 345 | 1 | hiro | static gchar *xface_black = "# c #000000"; |
| 346 | 1 | hiro | static gchar *xface_white = ". c #ffffff"; |
| 347 | 1 | hiro | |
| 348 | 1 | hiro | gint i, line = 0;
|
| 349 | 1 | hiro | const guchar *p;
|
| 350 | 1 | hiro | gchar buf[WIDTH * 4 + 1]; /* 4 = strlen("0x0000") */ |
| 351 | 1 | hiro | |
| 352 | 583 | hiro | p = (const guchar *)xface;
|
| 353 | 1 | hiro | |
| 354 | 1 | hiro | strcpy(xpm[line++], xface_header); |
| 355 | 1 | hiro | strcpy(xpm[line++], xface_black); |
| 356 | 1 | hiro | strcpy(xpm[line++], xface_white); |
| 357 | 1 | hiro | |
| 358 | 1 | hiro | for (i = 0; i < HEIGHT; i++) { |
| 359 | 1 | hiro | gint col; |
| 360 | 1 | hiro | |
| 361 | 1 | hiro | buf[0] = '\0'; |
| 362 | 1 | hiro | |
| 363 | 1 | hiro | for (col = 0; col < 3; col++) { |
| 364 | 1 | hiro | gint figure; |
| 365 | 1 | hiro | |
| 366 | 1 | hiro | p += 2; /* skip '0x' */ |
| 367 | 1 | hiro | |
| 368 | 1 | hiro | for (figure = 0; figure < 4; figure++) { |
| 369 | 1 | hiro | gint n = 0;
|
| 370 | 1 | hiro | |
| 371 | 1 | hiro | if ('0' <= *p && *p <= '9') { |
| 372 | 1 | hiro | n = *p - '0';
|
| 373 | 1 | hiro | } else if ('a' <= *p && *p <= 'f') { |
| 374 | 1 | hiro | n = *p - 'a' + 10; |
| 375 | 1 | hiro | } else if ('A' <= *p && *p <= 'F') { |
| 376 | 1 | hiro | n = *p - 'A' + 10; |
| 377 | 1 | hiro | } |
| 378 | 1 | hiro | |
| 379 | 1 | hiro | strcat(buf, bit_pattern[n]); |
| 380 | 1 | hiro | p++; /* skip ',' */
|
| 381 | 1 | hiro | } |
| 382 | 1 | hiro | |
| 383 | 1 | hiro | p++; /* skip '\n' */
|
| 384 | 1 | hiro | } |
| 385 | 1 | hiro | |
| 386 | 1 | hiro | strcpy(xpm[line++], buf); |
| 387 | 1 | hiro | p++; |
| 388 | 1 | hiro | } |
| 389 | 1 | hiro | |
| 390 | 1 | hiro | return 0; |
| 391 | 1 | hiro | } |
| 392 | 1 | hiro | #endif |