diff --git a/src/icons.c b/src/icons.c index 5deeffc..82c1d5d 100644 --- a/src/icons.c +++ b/src/icons.c @@ -1,182 +1,196 @@ /* icons.c - GPA icons * Copyright (C) 2000, 2001 OpenIT GmbH Copyright (C) 2008 g10 Code GmbH. This file is part of GPA. GPA is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GPA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include "i18n.h" #include "icons.h" -#include "verify.xpm" -#include "blue_key.xpm" -#include "blue_yellow_key.xpm" -#include "blue_yellow_cardkey.xpm" -#include "brief.xpm" -#include "decrypt.xpm" -#include "detailed.xpm" -#include "edit.xpm" -#include "encrypt.xpm" -#include "export.xpm" -#include "gpa_blue_key.xpm" -#include "gpa_logo.xpm" -#include "gpa_yellow_key.xpm" -#include "import.xpm" -#include "keyring.xpm" -#include "keyringeditor.xpm" -#include "sign.xpm" -#include "wizard_backup.xpm" -#include "wizard_genkey.xpm" -#include "smartcard.xpm" - - -struct { - const char *name; - char **xpm; -} xpms[] = { - { "gpa_logo", gpa_logo_xpm}, - { GPA_STOCK_ENCRYPT, encrypt_xpm }, - { GPA_STOCK_DECRYPT, decrypt_xpm }, - { GPA_STOCK_SIGN, sign_xpm }, - { GPA_STOCK_VERIFY, verify_xpm }, - { GPA_STOCK_KEYMAN_SIMPLE, keyringeditor_xpm }, - { GPA_STOCK_EXPORT, export_xpm }, - { GPA_STOCK_IMPORT, import_xpm }, - { GPA_STOCK_BRIEF, brief_xpm }, - { GPA_STOCK_DETAILED, detailed_xpm }, - { GPA_STOCK_EDIT, edit_xpm }, - { GPA_STOCK_KEYMAN, keyring_xpm }, - { "gpa_blue_key", gpa_blue_key_xpm }, - { "gpa_yellow_key", gpa_yellow_key_xpm }, - { GPA_STOCK_PUBLIC_KEY, blue_key_xpm }, - { GPA_STOCK_SECRET_KEY, blue_yellow_key_xpm }, - { GPA_STOCK_SECRET_CARDKEY, blue_yellow_cardkey_xpm }, - { "wizard_genkey", wizard_genkey_xpm}, - { "wizard_backup", wizard_backup_xpm}, - { GPA_STOCK_CARDMAN, smartcard_xpm }, - { NULL, NULL } -}; - - - -GdkPixbuf * -gpa_create_icon_pixbuf (const char *name) -{ - char **xpm = NULL; - int i; - - for (i = 0; xpms[i].name; i++) - if (! strcmp (xpms[i].name, name)) - { - xpm = xpms[i].xpm; - break; - } - - if (! xpm) - { - fprintf (stderr, "Icon `%s' not found\n", name); - fflush (stderr); - return NULL; - } - - return gdk_pixbuf_new_from_xpm_data ((const char**) xpm); -} - +#include "org.gnupg.gpa.src.h" + +#include "gpa.h" + +const char *icons_string = + "" + // blue_key.xpm + // blue_yellow_cardkey.xpm + // blue_yellow_key.xpm + // brief.xpm + "" + "True" + "False" + "brief.xpm" + "1" + "" + // clipboard + "" + "True" + "False" + "task-due" + "1" + "" + // decrypt.xpm + "" + "True" + "False" + "decrypt.xpm" + "1" + "" + // delete.xpm + "" + "True" + "False" + "delete.xpm" + "1" + "" + // detailed.xpm + "" + "True" + "False" + "detailed.xpm" + "1" + "" + // edit.xpm + "" + "True" + "False" + "edit.xpm" + "1" + "" + // encrypt.xpm + "" + "True" + "False" + "encrypt.xpm" + "1" + "" + // export.xpm + "" + "True" + "False" + "export.xpm" + "1" + "" + // floppy.xpm + // folder.xpm + // gpa_blue_key.xpm + // gpa_logo.xpm + "" // gpa_yellow_key.xpm + // harddisk.xpm + // help.xpm + // import.xpm + "" + "True" + "False" + "import.xpm" + "1" + "" + // keyring.xpm + "" + "True" + "True" + "keyring.xpm" + "1" + "" + // keyringeditor.xpm + "" + "True" + "True" + "keyringeditor.xpm" + "1" + "" + // open_folder.xpm + // openfile.xpm + // sign.xpm + "" + "True" + "False" + "sign.xpm" + "1" + "" + // smartcard.xpm + "" + "True" + "False" + "/org/gnupg/gpa/smartcard.xpm" + "1" + "" + // verify + "" + "True" + "False" + "/org/gnupg/gpa/verify.xpm" + "1" + "" + // wizard_backup + "" + "True" + "False" + "/org/gnupg/gpa/wizard_backup.xpm" + "1" + "" + // wizard_genkey + "" + "True" + "False" + "/org/gnupg/gpa/wizard_genkey.xpm" + "1" + "" + ""; static void register_stock_icons (void) { - GdkPixbuf *pixbuf; - GtkIconFactory *icon_factory; - GtkIconSet *icon_set; - GtkIconSource *icon_source; - gint i; - - icon_factory = gtk_icon_factory_new (); - - for (i = 0; xpms[i].name; i++) - { - icon_set = gtk_icon_set_new (); - icon_source = gtk_icon_source_new (); - - pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) xpms[i].xpm); - gtk_icon_source_set_pixbuf (icon_source, pixbuf); - gtk_icon_source_set_direction_wildcarded (icon_source, TRUE); - gtk_icon_source_set_state_wildcarded (icon_source, TRUE); - if (! strcmp (xpms[i].name, GPA_STOCK_PUBLIC_KEY) - || ! strcmp (xpms[i].name, GPA_STOCK_SECRET_KEY) - || ! strcmp (xpms[i].name, GPA_STOCK_SECRET_CARDKEY)) - { - /* FIXME: For the keylist icons, we disable scaling for now - for best visual results. */ - gtk_icon_source_set_size_wildcarded (icon_source, FALSE); - gtk_icon_source_set_size (icon_source, GTK_ICON_SIZE_LARGE_TOOLBAR); - } - - gtk_icon_set_add_source (icon_set, icon_source); - gtk_icon_source_free (icon_source); - gtk_icon_factory_add (icon_factory, xpms[i].name, icon_set); - gtk_icon_set_unref (icon_set); - } - - /* Add a fake stock icon for the clipboard window. */ - icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_PASTE); - icon_set = gtk_icon_set_copy (icon_set); - gtk_icon_factory_add (icon_factory, GPA_STOCK_CLIPBOARD, icon_set); - - /* Add a fake stock icon for the file manager window. */ - icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_DIRECTORY); - icon_set = gtk_icon_set_copy (icon_set); - gtk_icon_factory_add (icon_factory, GPA_STOCK_FILEMAN, icon_set); - - gtk_icon_factory_add_default (icon_factory); - - g_object_unref (icon_factory); + GdkDisplay *display = gdk_display_get_default(); + GdkScreen *screen = gdk_display_get_default_screen (display); + + g_application_set_resource_base_path (G_APPLICATION (get_gpa_application ()), "/org/gnupg/gpa"); + + //GtkIconTheme *icon_theme = gtk_icon_theme_new (); + GtkIconTheme *icon_theme = gtk_icon_theme_get_for_screen (screen); + + GResource *resource = org_get_resource (); + + g_resources_register (resource); + gtk_icon_theme_add_resource_path (icon_theme, "/org/gnupg/gpa"); + } void gpa_register_stock_items (void) { - static const GtkStockItem items[] = - { - { GPA_STOCK_SIGN, N_("_Sign"), 0, 0, PACKAGE }, - { GPA_STOCK_VERIFY, N_("_Verify"), 0, 0, PACKAGE }, - { GPA_STOCK_ENCRYPT, N_("_Encrypt"), 0, 0, PACKAGE }, - { GPA_STOCK_DECRYPT, N_("_Decrypt"), 0, 0, PACKAGE }, - { GPA_STOCK_BRIEF, N_("_Brief"), 0, 0, PACKAGE }, - { GPA_STOCK_DETAILED, N_("_Detailed"), 0, 0, PACKAGE }, - { GPA_STOCK_KEYMAN, N_("_Keyring Manager"), 0, 0, PACKAGE }, - { GPA_STOCK_CLIPBOARD, N_("_Clipboard"), 0, 0, PACKAGE }, - { GPA_STOCK_FILEMAN, N_("_File Manager"), 0, 0, PACKAGE }, - { GPA_STOCK_CARDMAN, N_("_Card Manager"), 0, 0, PACKAGE } - }; - register_stock_icons (); - gtk_stock_add_static (items, G_N_ELEMENTS (items)); } diff --git a/src/icons.h b/src/icons.h index 0dc892e..b201fc6 100644 --- a/src/icons.h +++ b/src/icons.h @@ -1,52 +1,55 @@ /* icons.h - Icons for GPA Copyright (C) 2000 G-N-U GmbH. Copyright (C) 2008 g10 Code GmbH. This file is part of GPA. GPA is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GPA is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef ICONS_H #define ICONS_H -GdkPixbuf *gpa_create_icon_pixbuf (const char *name); +// GdkPixbuf *gpa_create_icon_pixbuf (const char *name); void gpa_register_stock_items (void); #define GPA_STOCK_SIGN "gpa-sign" #define GPA_STOCK_VERIFY "gpa-verify" #define GPA_STOCK_ENCRYPT "gpa-encrypt" #define GPA_STOCK_DECRYPT "gpa-decrypt" /* Windows items. */ #define GPA_STOCK_KEYMAN "gpa-keyring" #define GPA_STOCK_KEYMAN_SIMPLE "gpa-keyringeditor" #define GPA_STOCK_FILEMAN "gpa-fileman" #define GPA_STOCK_CLIPBOARD "gpa-clipboard" #define GPA_STOCK_CARDMAN "gpa-cardman" /* Toolbar in key manager. */ #define GPA_STOCK_BRIEF "gpa-brief" #define GPA_STOCK_DETAILED "gpa-detailed" #define GPA_STOCK_EDIT "gpa-edit" #define GPA_STOCK_IMPORT "gpa-import" #define GPA_STOCK_EXPORT "gpa-export" #define GPA_STOCK_BACKUP "gpa-backup" #define GPA_STOCK_SECRET_CARDKEY "gpa-secret-cardkey" #define GPA_STOCK_SECRET_KEY "gpa-secret-key" #define GPA_STOCK_PUBLIC_KEY "gpa-public-key" +extern const char *icons_string; + + #endif /*ICONS_H*/