1 /* logjam - a GTK client for LiveJournal.
2 * Copyright (C) 2000-2003 Evan Martin <evan@livejournal.com>
4 * vim: tabstop=4 shiftwidth=4 noexpandtab :
7 #include <glib/gi18n.h>
8 #include <gtk/gtkiconfactory.h>
9 #include <gtk/gtkwindow.h>
10 #include <gtk/gtkstock.h>
15 static GtkStockItem logjam_stock_items
[] = {
16 /* XXX we shouldn't need those spaces in there for this to look good. :( */
17 { "logjam-submit", N_(" Submit "), 0, 0, "logjam" }
21 inline_to_listpixbuf(const guint8
*data
) {
23 gint width
, height
, sourcewidth
, sourceheight
;
25 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU
, &width
, &height
);
26 height
-= 5; /* FIXME: slightly smaller looks good, but it shouldn't. */
27 pb
= gdk_pixbuf_new_from_inline(-1, data
, FALSE
, NULL
);
29 /* now adjust width to be proportionate to the height for this icon. */
30 sourceheight
= gdk_pixbuf_get_height(pb
);
31 sourcewidth
= gdk_pixbuf_get_width(pb
);
32 width
= sourcewidth
* height
/ sourceheight
;
34 spb
= gdk_pixbuf_scale_simple(pb
, width
, height
, GDK_INTERP_BILINEAR
);
40 icons_rarrow_pixbuf(void) {
41 return inline_to_listpixbuf(logjam_rarrow
);
44 icons_larrow_pixbuf(void) {
45 return inline_to_listpixbuf(logjam_larrow
);
48 icons_lrarrow_pixbuf(void) {
49 return inline_to_listpixbuf(logjam_lrarrow
);
53 add(GtkIconFactory
*factory
,
54 const guchar
*inline_data
,
55 const gchar
*stock_id
) {
59 pixbuf
= gdk_pixbuf_new_from_inline(-1, inline_data
, FALSE
, NULL
);
60 set
= gtk_icon_set_new_from_pixbuf(pixbuf
);
61 g_object_unref(G_OBJECT(pixbuf
));
63 gtk_icon_factory_add(factory
, stock_id
, set
);
64 gtk_icon_set_unref(set
);
70 icons_initialize(void) {
71 GtkIconFactory
*factory
;
75 factory
= gtk_icon_factory_new();
76 goat
= add(factory
, logjam_goat
, "logjam-goat");
77 add(factory
, logjam_pencil
, "logjam-server");
78 add(factory
, logjam_ljuser
, "logjam-ljuser");
79 add(factory
, logjam_ljcomm
, "logjam-ljcomm");
80 add(factory
, logjam_protected
, "logjam-protected");
81 add(factory
, logjam_private
, "logjam-private");
82 gtk_icon_factory_add_default(factory
);
84 l
= g_list_append(NULL
, goat
);
85 gtk_window_set_default_icon_list(l
);
88 gtk_stock_add_static(logjam_stock_items
, G_N_ELEMENTS(logjam_stock_items
));
93 icons_load_throbber(GdkPixbuf
*pbs
[]) {
99 gtk_icon_size_lookup(GTK_ICON_SIZE_DIALOG
, &w
, &h
);
101 for (i
= 0; i
< THROBBER_COUNT
; i
++) {
103 case 0: data
= logjam_throbber_1
; break;
104 case 1: data
= logjam_throbber_2
; break;
105 case 2: data
= logjam_throbber_3
; break;
106 case 3: data
= logjam_throbber_4
; break;
107 case 4: data
= logjam_throbber_5
; break;
108 case 5: data
= logjam_throbber_6
; break;
109 case 6: data
= logjam_throbber_7
; break;
110 case 7: data
= logjam_throbber_8
; break;
112 g_warning("tried to load unknown throbber %d.", i
);
115 pb
= gdk_pixbuf_new_from_inline(-1, data
, FALSE
, NULL
);
116 pbs
[i
] = gdk_pixbuf_scale_simple(pb
, w
, h
, GDK_INTERP_BILINEAR
);
117 g_object_unref(G_OBJECT(pb
));
120 #endif /* HAVE_LIBRSVG */