1 /* logjam - a GTK client for LiveJournal.
2 * Copyright (C) 2000-2003 Evan Martin <evan@livejournal.com>
5 #include <glib/gi18n.h>
6 #include <gtk/gtkiconfactory.h>
7 #include <gtk/gtkwindow.h>
8 #include <gtk/gtkstock.h>
14 static const GtkStockItem logjam_stock_items
[] = {
15 /* XXX we shouldn't need those spaces in there for this to look good. :( */
16 {"logjam-submit", N_(" Submit "), 0, 0, "logjam"}
20 static GdkPixbuf
*inline_to_listpixbuf (const guint8
*data
) {
22 gint width
, height
, sourcewidth
, sourceheight
;
24 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU
, &width
, &height
);
25 height
-= 5; /* FIXME: slightly smaller looks good, but it shouldn't. */
26 pb
= gdk_pixbuf_new_from_inline(-1, data
, FALSE
, NULL
);
28 /* now adjust width to be proportionate to the height for this icon. */
29 sourceheight
= gdk_pixbuf_get_height(pb
);
30 sourcewidth
= gdk_pixbuf_get_width(pb
);
31 width
= sourcewidth
*height
/sourceheight
;
33 spb
= gdk_pixbuf_scale_simple(pb
, width
, height
, GDK_INTERP_BILINEAR
);
40 GdkPixbuf
*icons_rarrow_pixbuf (void) { return inline_to_listpixbuf(logjam_rarrow
); }
41 GdkPixbuf
*icons_larrow_pixbuf (void) { return inline_to_listpixbuf(logjam_larrow
); }
42 GdkPixbuf
*icons_lrarrow_pixbuf (void) { return inline_to_listpixbuf(logjam_lrarrow
); }
45 static GdkPixbuf
*add (GtkIconFactory
*factory
, const guchar
*inline_data
, const gchar
*stock_id
) {
49 pixbuf
= gdk_pixbuf_new_from_inline(-1, inline_data
, FALSE
, NULL
);
50 set
= gtk_icon_set_new_from_pixbuf(pixbuf
);
51 g_object_unref(G_OBJECT(pixbuf
));
53 gtk_icon_factory_add(factory
, stock_id
, set
);
54 gtk_icon_set_unref(set
);
60 void icons_initialize (void) {
61 GtkIconFactory
*factory
;
65 factory
= gtk_icon_factory_new();
66 goat
= add(factory
, logjam_goat
, "logjam-goat");
67 add(factory
, logjam_pencil
, "logjam-server");
68 add(factory
, logjam_ljuser
, "logjam-ljuser");
69 add(factory
, logjam_ljcomm
, "logjam-ljcomm");
70 add(factory
, logjam_protected
, "logjam-protected");
71 add(factory
, logjam_private
, "logjam-private");
72 gtk_icon_factory_add_default(factory
);
74 l
= g_list_append(NULL
, goat
);
75 gtk_window_set_default_icon_list(l
);
78 gtk_stock_add_static(logjam_stock_items
, G_N_ELEMENTS(logjam_stock_items
));
83 void icons_load_throbber (GdkPixbuf
*pbs
[]) {
88 gtk_icon_size_lookup(GTK_ICON_SIZE_DIALOG
, &w
, &h
);
89 for (i
= 0; i
< THROBBER_COUNT
; ++i
) {
91 case 0: data
= logjam_throbber_1
; break;
92 case 1: data
= logjam_throbber_2
; break;
93 case 2: data
= logjam_throbber_3
; break;
94 case 3: data
= logjam_throbber_4
; break;
95 case 4: data
= logjam_throbber_5
; break;
96 case 5: data
= logjam_throbber_6
; break;
97 case 6: data
= logjam_throbber_7
; break;
98 case 7: data
= logjam_throbber_8
; break;
99 default: g_warning("tried to load unknown throbber %d.", i
); return;
101 pb
= gdk_pixbuf_new_from_inline(-1, data
, FALSE
, NULL
);
102 pbs
[i
] = gdk_pixbuf_scale_simple(pb
, w
, h
, GDK_INTERP_BILINEAR
);
103 g_object_unref(G_OBJECT(pb
));
106 #endif /* HAVE_LIBRSVG */