2001-12-22 01:30:32 +01:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
|
|
|
* Copyright (C) 1999-2001 Hiroyuki Yamamoto
|
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2002-02-12 21:58:47 +01:00
|
|
|
#include "defs.h"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include <glib.h>
|
|
|
|
#include <gtk/gtkwidget.h>
|
2003-10-05 12:10:30 +02:00
|
|
|
#include <gtk/gtkimage.h>
|
2002-02-11 20:46:04 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <dirent.h>
|
2001-12-22 01:30:32 +01:00
|
|
|
|
|
|
|
#include "stock_pixmap.h"
|
|
|
|
#include "gtkutils.h"
|
2002-02-12 21:58:47 +01:00
|
|
|
#include "utils.h"
|
2002-02-11 20:46:04 +01:00
|
|
|
#include "prefs_common.h"
|
2001-12-22 01:30:32 +01:00
|
|
|
|
|
|
|
#include "pixmaps/address.xpm"
|
|
|
|
#include "pixmaps/book.xpm"
|
|
|
|
#include "pixmaps/category.xpm"
|
|
|
|
#include "pixmaps/checkbox_off.xpm"
|
|
|
|
#include "pixmaps/checkbox_on.xpm"
|
|
|
|
#include "pixmaps/clip.xpm"
|
2001-12-27 08:17:19 +01:00
|
|
|
#include "pixmaps/clipkey.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/complete.xpm"
|
|
|
|
#include "pixmaps/continue.xpm"
|
|
|
|
#include "pixmaps/deleted.xpm"
|
2002-02-11 20:46:04 +01:00
|
|
|
#include "pixmaps/dir_close.xpm"
|
|
|
|
#include "pixmaps/dir_open.xpm"
|
|
|
|
#include "pixmaps/dir_open_hrm.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/error.xpm"
|
|
|
|
#include "pixmaps/forwarded.xpm"
|
|
|
|
#include "pixmaps/group.xpm"
|
|
|
|
#include "pixmaps/inbox.xpm"
|
2002-02-11 20:46:04 +01:00
|
|
|
#include "pixmaps/inbox_hrm.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/interface.xpm"
|
|
|
|
#include "pixmaps/jpilot.xpm"
|
2001-12-27 08:17:19 +01:00
|
|
|
#include "pixmaps/key.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/ldap.xpm"
|
|
|
|
#include "pixmaps/linewrap.xpm"
|
|
|
|
#include "pixmaps/mark.xpm"
|
2001-12-24 00:22:56 +01:00
|
|
|
#include "pixmaps/locked.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/new.xpm"
|
|
|
|
#include "pixmaps/outbox.xpm"
|
2002-02-11 20:46:04 +01:00
|
|
|
#include "pixmaps/outbox_hrm.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/replied.xpm"
|
2002-02-11 20:46:04 +01:00
|
|
|
#include "pixmaps/close.xpm"
|
|
|
|
#include "pixmaps/down_arrow.xpm"
|
2002-08-05 19:56:35 +02:00
|
|
|
#include "pixmaps/up_arrow.xpm"
|
2002-02-11 20:46:04 +01:00
|
|
|
#include "pixmaps/exec.xpm"
|
|
|
|
#include "pixmaps/mail.xpm"
|
|
|
|
#include "pixmaps/mail_attach.xpm"
|
|
|
|
#include "pixmaps/mail_compose.xpm"
|
|
|
|
#include "pixmaps/mail_forward.xpm"
|
|
|
|
#include "pixmaps/mail_receive.xpm"
|
|
|
|
#include "pixmaps/mail_receive_all.xpm"
|
|
|
|
#include "pixmaps/mail_reply.xpm"
|
|
|
|
#include "pixmaps/mail_reply_to_all.xpm"
|
|
|
|
#include "pixmaps/mail_reply_to_author.xpm"
|
|
|
|
#include "pixmaps/mail_send.xpm"
|
|
|
|
#include "pixmaps/mail_send_queue.xpm"
|
|
|
|
#include "pixmaps/news_compose.xpm"
|
|
|
|
#include "pixmaps/paste.xpm"
|
|
|
|
#include "pixmaps/preferences.xpm"
|
|
|
|
#include "pixmaps/properties.xpm"
|
|
|
|
#include "pixmaps/sylpheed_logo.xpm"
|
|
|
|
#include "pixmaps/address_book.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/trash.xpm"
|
2002-02-11 20:46:04 +01:00
|
|
|
#include "pixmaps/trash_hrm.xpm"
|
2001-12-22 01:30:32 +01:00
|
|
|
#include "pixmaps/unread.xpm"
|
|
|
|
#include "pixmaps/vcard.xpm"
|
2001-12-25 01:11:23 +01:00
|
|
|
#include "pixmaps/ignorethread.xpm"
|
2004-01-12 22:28:31 +01:00
|
|
|
#include "pixmaps/online.xpm"
|
|
|
|
#include "pixmaps/offline.xpm"
|
2002-07-07 22:46:30 +02:00
|
|
|
#include "pixmaps/notice_warn.xpm"
|
|
|
|
#include "pixmaps/notice_error.xpm"
|
|
|
|
#include "pixmaps/notice_note.xpm"
|
2002-08-22 16:35:57 +02:00
|
|
|
#include "pixmaps/quicksearch.xpm"
|
2003-01-31 16:55:56 +01:00
|
|
|
#include "pixmaps/gpg_signed.xpm"
|
2003-02-18 10:51:35 +01:00
|
|
|
#include "pixmaps/drafts_close.xpm"
|
2003-02-18 11:26:15 +01:00
|
|
|
#include "pixmaps/drafts_open.xpm"
|
2003-07-19 15:50:29 +02:00
|
|
|
#include "pixmaps/mime_text_plain.xpm"
|
|
|
|
#include "pixmaps/mime_text_html.xpm"
|
|
|
|
#include "pixmaps/mime_application.xpm"
|
|
|
|
#include "pixmaps/mime_image.xpm"
|
|
|
|
#include "pixmaps/mime_audio.xpm"
|
|
|
|
#include "pixmaps/mime_text_enriched.xpm"
|
|
|
|
#include "pixmaps/mime_unknown.xpm"
|
2004-01-12 22:28:31 +01:00
|
|
|
#include "pixmaps/privacy_signed.xpm"
|
|
|
|
#include "pixmaps/privacy_passed.xpm"
|
|
|
|
#include "pixmaps/privacy_failed.xpm"
|
|
|
|
#include "pixmaps/privacy_unknown.xpm"
|
|
|
|
#include "pixmaps/privacy_expired.xpm"
|
|
|
|
#include "pixmaps/privacy_warn.xpm"
|
|
|
|
#include "pixmaps/mime_message.xpm"
|
2003-09-07 21:25:35 +02:00
|
|
|
#include "pixmaps/address_search.xpm"
|
2004-01-12 22:28:31 +01:00
|
|
|
#include "pixmaps/check_spelling.xpm"
|
2003-07-19 15:50:29 +02:00
|
|
|
|
2001-12-22 01:30:32 +01:00
|
|
|
typedef struct _StockPixmapData StockPixmapData;
|
|
|
|
|
|
|
|
struct _StockPixmapData
|
|
|
|
{
|
|
|
|
gchar **data;
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
GdkBitmap *mask;
|
2002-02-11 20:46:04 +01:00
|
|
|
gchar *file;
|
|
|
|
gchar *icon_path;
|
2001-12-22 01:30:32 +01:00
|
|
|
};
|
|
|
|
|
2002-02-11 20:46:04 +01:00
|
|
|
static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname);
|
|
|
|
|
2001-12-22 01:30:32 +01:00
|
|
|
static StockPixmapData pixmaps[] =
|
|
|
|
{
|
2004-01-12 22:28:31 +01:00
|
|
|
{address_xpm , NULL, NULL, "address", " "},
|
|
|
|
{address_book_xpm , NULL, NULL, "address_book", " "},
|
|
|
|
{address_search_xpm , NULL, NULL, "address_search", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{book_xpm , NULL, NULL, "book", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{category_xpm , NULL, NULL, "category", " "},
|
|
|
|
{checkbox_off_xpm , NULL, NULL, "checkbox_off", " "},
|
|
|
|
{checkbox_on_xpm , NULL, NULL, "checkbox_on", " "},
|
|
|
|
{check_spelling_xpm , NULL, NULL, "check_spelling", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{clip_xpm , NULL, NULL, "clip", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{clipkey_xpm , NULL, NULL, "clipkey", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{close_xpm , NULL, NULL, "close", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{complete_xpm , NULL, NULL, "complete", " "},
|
|
|
|
{continue_xpm , NULL, NULL, "continue", " "},
|
|
|
|
{deleted_xpm , NULL, NULL, "deleted", " "},
|
|
|
|
{dir_close_xpm , NULL, NULL, "dir_close", " "},
|
|
|
|
{dir_close_xpm , NULL, NULL, "dir_close_hrm", " "},
|
|
|
|
{dir_open_xpm , NULL, NULL, "dir_open", " "},
|
|
|
|
{dir_open_hrm_xpm , NULL, NULL, "dir_open_hrm", " "},
|
|
|
|
{down_arrow_xpm , NULL, NULL, "down_arrow", " "},
|
|
|
|
{up_arrow_xpm , NULL, NULL, "up_arrow", " "},
|
|
|
|
{mail_compose_xpm , NULL, NULL, "edit_extern", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{error_xpm , NULL, NULL, "error", " "},
|
|
|
|
{exec_xpm , NULL, NULL, "exec", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{forwarded_xpm , NULL, NULL, "forwarded", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{group_xpm , NULL, NULL, "group", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{ignorethread_xpm , NULL, NULL, "ignorethread", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{inbox_xpm , NULL, NULL, "inbox_close", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{inbox_hrm_xpm , NULL, NULL, "inbox_close_hrm", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{inbox_xpm , NULL, NULL, "inbox_open", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{inbox_hrm_xpm , NULL, NULL, "inbox_open_hrm", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{paste_xpm , NULL, NULL, "insert_file", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{interface_xpm , NULL, NULL, "interface", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{jpilot_xpm , NULL, NULL, "jpilot", " "},
|
|
|
|
{key_xpm , NULL, NULL, "key", " "},
|
|
|
|
{ldap_xpm , NULL, NULL, "ldap", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{linewrap_xpm , NULL, NULL, "linewrap", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{locked_xpm , NULL, NULL, "locked", " "},
|
|
|
|
{mail_xpm , NULL, NULL, "mail", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{mail_attach_xpm , NULL, NULL, "mail_attach", " "},
|
|
|
|
{mail_compose_xpm , NULL, NULL, "mail_compose", " "},
|
|
|
|
{mail_forward_xpm , NULL, NULL, "mail_forward", " "},
|
|
|
|
{mail_receive_xpm , NULL, NULL, "mail_receive", " "},
|
|
|
|
{mail_receive_all_xpm , NULL, NULL, "mail_receive_all", " "},
|
|
|
|
{mail_reply_xpm , NULL, NULL, "mail_reply", " "},
|
|
|
|
{mail_reply_to_all_xpm , NULL, NULL, "mail_reply_to_all", " "},
|
|
|
|
{mail_reply_to_author_xpm , NULL, NULL, "mail_reply_to_author", " "},
|
|
|
|
{mail_send_xpm , NULL, NULL, "mail_send", " "},
|
|
|
|
{mail_send_queue_xpm , NULL, NULL, "mail_send_queue", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{mail_xpm , NULL, NULL, "mail_sign", " "},
|
|
|
|
{mark_xpm , NULL, NULL, "mark", " "},
|
|
|
|
{new_xpm , NULL, NULL, "new", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{news_compose_xpm , NULL, NULL, "news_compose", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{outbox_xpm , NULL, NULL, "outbox_close", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{outbox_hrm_xpm , NULL, NULL, "outbox_close_hrm", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{outbox_xpm , NULL, NULL, "outbox_open", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{outbox_hrm_xpm , NULL, NULL, "outbox_open_hrm", " "},
|
|
|
|
{replied_xpm , NULL, NULL, "replied", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{paste_xpm , NULL, NULL, "paste", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{preferences_xpm , NULL, NULL, "preferences", " "},
|
|
|
|
{properties_xpm , NULL, NULL, "properties", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{outbox_xpm , NULL, NULL, "queue_close", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{outbox_hrm_xpm , NULL, NULL, "queue_close_hrm", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{outbox_xpm , NULL, NULL, "queue_open", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{outbox_hrm_xpm , NULL, NULL, "queue_open_hrm", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{trash_xpm , NULL, NULL, "trash_open", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{trash_hrm_xpm , NULL, NULL, "trash_open_hrm", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{trash_xpm , NULL, NULL, "trash_close", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{trash_hrm_xpm , NULL, NULL, "trash_close_hrm", " "},
|
2002-02-11 20:46:04 +01:00
|
|
|
{unread_xpm , NULL, NULL, "unread", " "},
|
|
|
|
{vcard_xpm , NULL, NULL, "vcard", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{online_xpm , NULL, NULL, "online", " "},
|
|
|
|
{offline_xpm , NULL, NULL, "offline", " "},
|
2002-07-07 22:46:30 +02:00
|
|
|
{notice_warn_xpm , NULL, NULL, "notice_warn", " "},
|
|
|
|
{notice_error_xpm , NULL, NULL, "notice_error", " "},
|
|
|
|
{notice_note_xpm , NULL, NULL, "notice_note", " "},
|
2002-08-22 16:35:57 +02:00
|
|
|
{quicksearch_xpm , NULL, NULL, "quicksearch", " "},
|
2003-01-31 16:55:56 +01:00
|
|
|
{gpg_signed_xpm , NULL, NULL, "gpg_signed", " "},
|
2003-02-18 10:51:35 +01:00
|
|
|
{drafts_close_xpm , NULL, NULL, "drafts_close", " "},
|
|
|
|
{drafts_open_xpm , NULL, NULL, "drafts_open", " "},
|
2003-07-19 15:50:29 +02:00
|
|
|
{mime_text_plain_xpm , NULL, NULL, "mime_text_plain", " "},
|
|
|
|
{mime_text_html_xpm , NULL, NULL, "mime_text_html", " "},
|
|
|
|
{mime_application_xpm , NULL, NULL, "mime_application", " "},
|
|
|
|
{mime_image_xpm , NULL, NULL, "mime_image", " "},
|
|
|
|
{mime_audio_xpm , NULL, NULL, "mime_audio", " "},
|
|
|
|
{mime_text_enriched_xpm , NULL, NULL, "mime_text_enriched", " "},
|
|
|
|
{mime_unknown_xpm , NULL, NULL, "mime_unknown", " "},
|
2004-01-12 22:28:31 +01:00
|
|
|
{privacy_signed_xpm , NULL, NULL, "privacy_signed", " "},
|
|
|
|
{privacy_passed_xpm , NULL, NULL, "privacy_passed", " "},
|
|
|
|
{privacy_failed_xpm , NULL, NULL, "privacy_failed", " "},
|
|
|
|
{privacy_unknown_xpm , NULL, NULL, "privacy_unknown", " "},
|
|
|
|
{privacy_expired_xpm , NULL, NULL, "privacy_expired", " "},
|
|
|
|
{privacy_warn_xpm , NULL, NULL, "privacy_warn", " "},
|
|
|
|
{mime_message_xpm , NULL, NULL, "mime_message", " "},
|
2002-12-24 15:22:27 +01:00
|
|
|
{sylpheed_logo_xpm , NULL, NULL, "sylpheed_logo", " "},
|
2001-12-22 01:30:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* return newly constructed GtkPixmap from GdkPixmap */
|
|
|
|
GtkWidget *stock_pixmap_widget(GtkWidget *window, StockPixmap icon)
|
|
|
|
{
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
GdkBitmap *mask;
|
|
|
|
|
|
|
|
g_return_val_if_fail(window != NULL, NULL);
|
|
|
|
g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
|
|
|
|
|
2002-02-12 22:57:15 +01:00
|
|
|
if (stock_pixmap_gdk(window, icon, &pixmap, &mask) != -1)
|
2003-10-05 12:10:30 +02:00
|
|
|
return gtk_image_new_from_pixmap(pixmap, mask);
|
2002-02-12 22:57:15 +01:00
|
|
|
|
|
|
|
return NULL;
|
2001-12-22 01:30:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* create GdkPixmap if it has not created yet */
|
|
|
|
gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
|
|
|
|
GdkPixmap **pixmap, GdkBitmap **mask)
|
|
|
|
{
|
|
|
|
StockPixmapData *pix_d;
|
|
|
|
|
|
|
|
if (pixmap) *pixmap = NULL;
|
|
|
|
if (mask) *mask = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail(window != NULL, -1);
|
|
|
|
g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1);
|
|
|
|
|
|
|
|
pix_d = &pixmaps[icon];
|
|
|
|
|
2002-02-11 20:46:04 +01:00
|
|
|
if (!pix_d->pixmap || (strcmp(pix_d->icon_path, prefs_common.pixmap_theme_path) != 0)) {
|
|
|
|
GdkPixmap *pix = NULL;
|
|
|
|
|
|
|
|
if (strcmp(prefs_common.pixmap_theme_path, DEFAULT_PIXMAP_THEME) != 0) {
|
|
|
|
if ( is_dir_exist(prefs_common.pixmap_theme_path) ) {
|
2002-02-12 21:58:47 +01:00
|
|
|
char *icon_file_name;
|
2002-02-11 20:46:04 +01:00
|
|
|
|
2002-02-12 21:58:47 +01:00
|
|
|
icon_file_name = g_strconcat(prefs_common.pixmap_theme_path,
|
|
|
|
G_DIR_SEPARATOR_S,
|
|
|
|
pix_d->file,
|
|
|
|
".xpm",
|
|
|
|
NULL);
|
2002-02-12 22:57:15 +01:00
|
|
|
if (is_file_exist(icon_file_name))
|
2002-02-11 20:46:04 +01:00
|
|
|
PIXMAP_CREATE_FROM_FILE(window, pix, pix_d->mask, icon_file_name);
|
2002-02-12 21:58:47 +01:00
|
|
|
if (pix)
|
|
|
|
pix_d->icon_path = prefs_common.pixmap_theme_path;
|
2002-02-11 20:46:04 +01:00
|
|
|
g_free(icon_file_name);
|
|
|
|
} else {
|
|
|
|
/* even the path does not exist (deleted between two sessions), so
|
|
|
|
set the preferences to the internal theme */
|
|
|
|
prefs_common.pixmap_theme_path = DEFAULT_PIXMAP_THEME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pix_d->pixmap = pix;
|
|
|
|
}
|
|
|
|
|
2001-12-22 01:30:32 +01:00
|
|
|
if (!pix_d->pixmap) {
|
2002-02-11 20:46:04 +01:00
|
|
|
PIXMAP_CREATE(window, pix_d->pixmap, pix_d->mask, pix_d->data);
|
2002-02-12 21:58:47 +01:00
|
|
|
if (pix_d->pixmap)
|
|
|
|
pix_d->icon_path = DEFAULT_PIXMAP_THEME;
|
2001-12-22 01:30:32 +01:00
|
|
|
}
|
|
|
|
|
2002-02-11 20:46:04 +01:00
|
|
|
g_return_val_if_fail(pix_d->pixmap != NULL, -1);
|
|
|
|
|
2002-02-12 21:58:47 +01:00
|
|
|
if (pixmap)
|
|
|
|
*pixmap = pix_d->pixmap;
|
|
|
|
if (mask)
|
|
|
|
*mask = pix_d->mask;
|
2001-12-22 01:30:32 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2002-02-11 20:46:04 +01:00
|
|
|
|
|
|
|
static void stock_pixmap_find_themes_in_dir(GList **list, const gchar *dirname)
|
|
|
|
{
|
2002-02-14 20:12:54 +01:00
|
|
|
struct dirent *d;
|
|
|
|
DIR *dp;
|
|
|
|
|
|
|
|
if ((dp = opendir(dirname)) == NULL) {
|
2003-08-29 15:48:48 +02:00
|
|
|
debug_print("dir %s not found, skipping theme scan", dirname);
|
2002-02-12 21:58:47 +01:00
|
|
|
return;
|
2002-02-14 20:12:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
while ((d = readdir(dp)) != NULL) {
|
2002-02-12 21:58:47 +01:00
|
|
|
gchar *entry;
|
|
|
|
gchar *fullentry;
|
|
|
|
|
2002-02-14 20:12:54 +01:00
|
|
|
entry = d->d_name;
|
2002-02-12 21:58:47 +01:00
|
|
|
fullentry = g_strconcat(dirname, G_DIR_SEPARATOR_S, entry, NULL);
|
|
|
|
|
|
|
|
if (strcmp(entry, ".") != 0 && strcmp(entry, "..") != 0 && is_dir_exist(fullentry)) {
|
|
|
|
gchar *filetoexist;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < N_STOCK_PIXMAPS; i++) {
|
|
|
|
filetoexist = g_strconcat(fullentry, G_DIR_SEPARATOR_S, pixmaps[i].file, ".xpm", NULL);
|
2002-02-12 22:57:15 +01:00
|
|
|
if (is_file_exist(filetoexist)) {
|
2002-02-12 21:58:47 +01:00
|
|
|
*list = g_list_append(*list, fullentry);
|
|
|
|
break;
|
2002-02-11 20:46:04 +01:00
|
|
|
}
|
|
|
|
}
|
2002-02-14 20:30:33 +01:00
|
|
|
g_free(filetoexist);
|
2002-02-12 21:58:47 +01:00
|
|
|
if (i == N_STOCK_PIXMAPS)
|
|
|
|
g_free(fullentry);
|
2002-02-14 20:30:33 +01:00
|
|
|
} else
|
|
|
|
g_free(fullentry);
|
2002-02-11 20:46:04 +01:00
|
|
|
}
|
2002-02-14 20:12:54 +01:00
|
|
|
closedir(dp);
|
2002-02-11 20:46:04 +01:00
|
|
|
}
|
|
|
|
|
2002-02-12 21:58:47 +01:00
|
|
|
GList *stock_pixmap_themes_list_new(void)
|
2002-02-11 20:46:04 +01:00
|
|
|
{
|
2002-02-12 21:58:47 +01:00
|
|
|
gchar *defaulttheme;
|
|
|
|
gchar *userthemes;
|
|
|
|
gchar *systemthemes;
|
|
|
|
GList *list = NULL;
|
2002-02-11 20:46:04 +01:00
|
|
|
|
2002-02-12 21:58:47 +01:00
|
|
|
defaulttheme = g_strdup(DEFAULT_PIXMAP_THEME);
|
|
|
|
userthemes = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S,
|
|
|
|
RC_DIR, G_DIR_SEPARATOR_S,
|
|
|
|
PIXMAP_THEME_DIR, NULL);
|
|
|
|
systemthemes = g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S,
|
|
|
|
PIXMAP_THEME_DIR, NULL);
|
|
|
|
|
|
|
|
list = g_list_append(list, defaulttheme);
|
2002-02-11 20:46:04 +01:00
|
|
|
|
2002-02-12 21:58:47 +01:00
|
|
|
stock_pixmap_find_themes_in_dir(&list, userthemes);
|
|
|
|
stock_pixmap_find_themes_in_dir(&list, systemthemes);
|
2002-02-12 22:57:15 +01:00
|
|
|
|
2002-02-11 20:46:04 +01:00
|
|
|
g_free(userthemes);
|
2002-02-12 21:58:47 +01:00
|
|
|
g_free(systemthemes);
|
|
|
|
return list;
|
2002-02-11 22:40:10 +01:00
|
|
|
}
|
2002-02-12 21:58:47 +01:00
|
|
|
|
|
|
|
void stock_pixmap_themes_list_free(GList *list)
|
|
|
|
{
|
|
|
|
GList *ptr;
|
|
|
|
|
|
|
|
for (ptr = g_list_first(list); ptr != NULL; ptr = g_list_next(ptr))
|
|
|
|
if (ptr->data)
|
|
|
|
g_free(ptr->data);
|
|
|
|
g_list_free(list);
|
|
|
|
}
|
|
|
|
|
2002-08-05 19:56:35 +02:00
|
|
|
gchar *stock_pixmap_get_name (StockPixmap icon)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL);
|
|
|
|
|
|
|
|
return pixmaps[icon].file;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
StockPixmap stock_pixmap_get_icon (gchar *file)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < N_STOCK_PIXMAPS; i++) {
|
|
|
|
if (strcmp (pixmaps[i].file, file) == 0)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|