Files
gnucash/src/gnome-utils/gnc-icons.c
David Hampton 1ef61103f4 Add new icons for invoices, adding a scheduled transaction, and the
jump action.  Fixes #339112.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13826 57a11ea4-9604-0410-9ed3-97b8803252fd
2006-04-22 04:02:21 +00:00

113 lines
3.8 KiB
C

/*
* gnc-icons.c -- Functions to create a GtkIconFactory for GnuCash
* Copyright (C) 2003 Jan Arne Petersen
* Author: Jan Arne Petersen <jpetersen@uni-bonn.de>
*/
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include "gnc-icons.h"
#include "gnc-gnome-utils.h"
static GtkStockItem items[] = {
{ GNC_STOCK_ACCOUNT, N_("Account"), 0, 0, NULL },
{ GNC_STOCK_DELETE_ACCOUNT, N_("_Delete Account"), 0, 0, NULL },
{ GNC_STOCK_EDIT_ACCOUNT, N_("_Edit Account"), 0, 0, NULL },
{ GNC_STOCK_NEW_ACCOUNT, N_("_New Account"), 0, 0, NULL },
{ GNC_STOCK_OPEN_ACCOUNT, N_("_Open Account"), 0, 0, NULL },
{ GNC_STOCK_TRANSFER, N_("_Transfer..."), 0, 0, NULL },
{ GNC_STOCK_SPLIT_TRANS, N_("S_plit Transaction"), 0, 0, NULL },
{ GNC_STOCK_JUMP_TO, N_("_Jump"), 0, 0, NULL },
};
typedef struct _item_file {
const gchar *stock_name;
const gchar *filename_lg;
const gchar *filename_sm;
} item_file;
static item_file item_files[] = {
{ GNC_STOCK_ACCOUNT, "account.png", "account-16.png"},
{ GNC_STOCK_DELETE_ACCOUNT, "delete-account.png", "delete-account-16.png"},
{ GNC_STOCK_EDIT_ACCOUNT, "edit-account.png", "edit-account-16.png"},
{ GNC_STOCK_NEW_ACCOUNT, "new-account.png", "new-account-16.png"},
{ GNC_STOCK_OPEN_ACCOUNT, "open-account.png", "open-account-16.png"},
{ GNC_STOCK_TRANSFER, "transfer.png", "transfer-16.png"},
{ GNC_STOCK_SCHEDULE, "gnc-sx-new.png", "gnc-sx-new-16.png"},
{ GNC_STOCK_SPLIT_TRANS, "split-transaction.png", "split-transaction-16.png"},
{ GNC_STOCK_JUMP_TO, "gnc-jumpto.png", "gnc-jumpto-16.png"},
{ GNC_STOCK_INVOICE, "gnc-invoice.png", "gnc-invoice-16.png"},
{ GNC_STOCK_INVOICE_POST, "gnc-invoice-post.png", "gnc-invoice-post-16.png"},
{ GNC_STOCK_INVOICE_UNPOST, "gnc-invoice-unpost.png", "gnc-invoice-unpost-16.png"},
{ GNC_STOCK_INVOICE_EDIT, "gnc-invoice-edit.png", "gnc-invoice-edit-16.png"},
{ 0 },
};
static void
gnc_add_stock_icon_pair (GtkIconFactory *factory,
const char *stock,
const char *filename1,
const char *filename2)
{
GtkIconSet *set;
GtkIconSource *source;
GdkPixbuf *pixbuf1, *pixbuf2;
char *fullname1, *fullname2;
/* Find the complete path names for these files */
fullname1 = gnc_gnome_locate_pixmap (filename1);
fullname2 = gnc_gnome_locate_pixmap (filename2);
g_assert (fullname1 && fullname2);
/* Load the pixbufs */
pixbuf1 = gnc_gnome_get_gdkpixbuf (filename1);
pixbuf2 = gnc_gnome_get_gdkpixbuf (filename2);
g_assert (pixbuf1 && pixbuf2);
/* Create the icon set */
set = gtk_icon_set_new ();
source = gtk_icon_source_new ();
gtk_icon_source_set_filename (source, fullname1);
gtk_icon_source_set_pixbuf (source, pixbuf1);
gtk_icon_set_add_source (set, source);
gtk_icon_source_free(source);
source = gtk_icon_source_new ();
gtk_icon_source_set_filename (source, fullname2);
gtk_icon_source_set_pixbuf (source, pixbuf2);
gtk_icon_source_set_size (source, GTK_ICON_SIZE_MENU);
gtk_icon_source_set_size_wildcarded (source, FALSE);
gtk_icon_set_add_source (set, source);
gtk_icon_source_free(source);
/* Add it to the factory */
gtk_icon_factory_add (factory, stock, set);
/* Cleanup */
gdk_pixbuf_unref (pixbuf2);
gdk_pixbuf_unref (pixbuf1);
g_free(fullname2);
g_free(fullname1);
gtk_icon_set_unref (set);
}
void
gnc_load_stock_icons (void)
{
GtkIconFactory *factory;
item_file *file;
/* Register our stock items */
gtk_stock_add (items, G_N_ELEMENTS (items));
/* Add our custom icon factory to the list of defaults */
factory = gtk_icon_factory_new ();
for (file = item_files; file->stock_name; file++) {
gnc_add_stock_icon_pair (factory, file->stock_name,
file->filename_lg, file->filename_sm);
}
gtk_icon_factory_add_default (factory);
}