mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 10:45:41 +00:00
added theme framework so clients can access theme data and made the
added theme framework so clients can access theme data and made the sidebar use it.
This commit is contained in:
parent
d6ae8859cc
commit
5be0629b8f
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2000-06-28 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
* libnautilus-extensions/Makefile.am:
|
||||
added nautilus-theme.c and nautilus-theme.h
|
||||
* libnautilus-extensions/nautilus-theme.c,h:
|
||||
(nautilus_theme_get_theme), (nautilus_theme_set_theme),
|
||||
(load_theme_document), (nautilus_theme_get_theme_data):
|
||||
added theme framework that allows clients to access theme information
|
||||
without knowing the underlying implementation
|
||||
* src/nautilus-sidebar.c: (nautilus_sidebar_read_theme):
|
||||
made the sidebar use the new theme framework
|
||||
* icons/default.xml:
|
||||
* icons/eazel/eazel.xml:
|
||||
* icons/vector/vector.xml:
|
||||
changed the icon container keyword for new framework
|
||||
|
||||
2000-06-27 Eskil Heyn Olsen <eskil@eazel.com>
|
||||
|
||||
* src/nautilus-view-frame.c:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<theme name="default">
|
||||
<sidebar SIDEBAR_BACKGROUND_COLOR="rgb:DDDD/DDDD/FFFF"/>
|
||||
<iconcontainer BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
|
||||
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
|
||||
</theme>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<theme name="eazel">
|
||||
<sidebar SIDEBAR_BACKGROUND_TILE_IMAGE="backgrounds/cork.png" SIDEBAR_BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
|
||||
<iconcontainer BACKGROUND_TILE_IMAGE="backgrounds/gnome.jpg" BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
|
||||
<directory BACKGROUND_TILE_IMAGE="backgrounds/gnome.jpg" BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
|
||||
</theme>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<theme name="vector">
|
||||
<sidebar SIDEBAR_BACKGROUND_TILE_IMAGE="backgrounds/blue_sky.png"/>
|
||||
<iconcontainer BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF-rgb:DDDD/DDDD/FFFF"/>
|
||||
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF-rgb:DDDD/DDDD/FFFF"/>
|
||||
</theme>
|
||||
|
|
|
@ -89,6 +89,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-string-picker.c \
|
||||
nautilus-string.c \
|
||||
nautilus-text-caption.c \
|
||||
nautilus-theme.c \
|
||||
nautilus-undo-context.c \
|
||||
nautilus-undo-manager.c \
|
||||
nautilus-undo-signal-handlers.c \
|
||||
|
@ -165,6 +166,7 @@ noinst_HEADERS = \
|
|||
nautilus-string-picker.h \
|
||||
nautilus-string.h \
|
||||
nautilus-text-caption.h \
|
||||
nautilus-theme.h \
|
||||
nautilus-undo-context.h \
|
||||
nautilus-undo-manager.h \
|
||||
nautilus-undo-signal-handlers.h \
|
||||
|
|
130
libnautilus-extensions/nautilus-theme.c
Normal file
130
libnautilus-extensions/nautilus-theme.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-theme.c: theme framework with xml-based theme definition files
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
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.
|
||||
|
||||
Author: Andy Hertzfeld <andy@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <parser.h>
|
||||
#include <xmlmemory.h>
|
||||
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
|
||||
#include "nautilus-file.h"
|
||||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-string.h"
|
||||
#include "nautilus-xml-extensions.h"
|
||||
#include "nautilus-global-preferences.h"
|
||||
#include "nautilus-preferences.h"
|
||||
|
||||
#include "nautilus-theme.h"
|
||||
|
||||
/* static globals to hold the last accessed theme file */
|
||||
static char *last_theme_name = NULL;
|
||||
static xmlDocPtr last_theme_document = NULL;
|
||||
|
||||
/* return the current theme by asking the preferences machinery */
|
||||
char *
|
||||
nautilus_theme_get_theme(void)
|
||||
{
|
||||
return nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
}
|
||||
|
||||
/* set the current theme */
|
||||
void
|
||||
nautilus_theme_set_theme(const char *new_theme)
|
||||
{
|
||||
char *old_theme;
|
||||
|
||||
old_theme = nautilus_theme_get_theme();
|
||||
if (nautilus_strcmp (old_theme, new_theme)) {
|
||||
nautilus_preferences_set (NAUTILUS_PREFERENCES_THEME, new_theme);
|
||||
}
|
||||
g_free (old_theme);
|
||||
}
|
||||
|
||||
/* load and parse a theme file */
|
||||
static xmlDocPtr
|
||||
load_theme_document (const char * theme_name)
|
||||
{
|
||||
xmlDocPtr theme_document;
|
||||
char *theme_path, *temp_str;
|
||||
|
||||
/* formulate the theme path name */
|
||||
if (strcmp(theme_name, "default") == 0) {
|
||||
theme_path = nautilus_pixmap_file ("default.xml");
|
||||
} else {
|
||||
temp_str = g_strdup_printf("%s/%s.xml", theme_name, theme_name);
|
||||
theme_path = nautilus_pixmap_file (temp_str);
|
||||
g_free(temp_str);
|
||||
}
|
||||
|
||||
/* load and parse the theme file */
|
||||
theme_document = xmlParseFile(theme_path);
|
||||
g_free(theme_path);
|
||||
|
||||
return theme_document;
|
||||
}
|
||||
|
||||
/* fetch data from the current theme. Cache the last theme file as a parsed xml document */
|
||||
char *
|
||||
nautilus_theme_get_theme_data(const char *resource_name, const char *property_name)
|
||||
{
|
||||
char *theme_name, *temp_str;
|
||||
char *theme_data;
|
||||
|
||||
xmlDocPtr theme_document;
|
||||
xmlNodePtr resource_node;
|
||||
|
||||
/* fetch the current theme name */
|
||||
theme_data = NULL;
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
if (nautilus_strcmp (theme_name, last_theme_name) == 0) {
|
||||
theme_document = last_theme_document;
|
||||
} else {
|
||||
/* release the old saved data, since the theme changed */
|
||||
if (last_theme_document)
|
||||
xmlFreeDoc (last_theme_document);
|
||||
g_free (last_theme_name);
|
||||
|
||||
last_theme_name = g_strdup (theme_name);
|
||||
last_theme_document = load_theme_document (theme_name);
|
||||
theme_document = last_theme_document;
|
||||
}
|
||||
|
||||
if (theme_document != NULL) {
|
||||
/* fetch the resource node */
|
||||
|
||||
resource_node = nautilus_xml_get_child_by_name(xmlDocGetRootElement (theme_document), resource_name);
|
||||
if (resource_node) {
|
||||
temp_str = xmlGetProp(resource_node, property_name);
|
||||
if (temp_str)
|
||||
theme_data = g_strdup (temp_str);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(theme_name);
|
||||
|
||||
return theme_data;
|
||||
}
|
39
libnautilus-extensions/nautilus-theme.h
Normal file
39
libnautilus-extensions/nautilus-theme.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-theme.h: theme framework with xml-based theme definition files
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
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.
|
||||
|
||||
Authors: Andy Hertzfeld <andy@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_THEME_H
|
||||
#define NAUTILUS_THEME_H
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/* get and set the current theme */
|
||||
char *nautilus_theme_get_theme(void);
|
||||
void nautilus_theme_set_theme(const char *new_theme);
|
||||
|
||||
/* fetch data from the current theme */
|
||||
char *nautilus_theme_get_theme_data(const char *resource_name, const char *property_name);
|
||||
|
||||
|
||||
#endif /* NAUTILUS_THEME_H */
|
|
@ -89,6 +89,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-string-picker.c \
|
||||
nautilus-string.c \
|
||||
nautilus-text-caption.c \
|
||||
nautilus-theme.c \
|
||||
nautilus-undo-context.c \
|
||||
nautilus-undo-manager.c \
|
||||
nautilus-undo-signal-handlers.c \
|
||||
|
@ -165,6 +166,7 @@ noinst_HEADERS = \
|
|||
nautilus-string-picker.h \
|
||||
nautilus-string.h \
|
||||
nautilus-text-caption.h \
|
||||
nautilus-theme.h \
|
||||
nautilus-undo-context.h \
|
||||
nautilus-undo-manager.h \
|
||||
nautilus-undo-signal-handlers.h \
|
||||
|
|
130
libnautilus-private/nautilus-theme.c
Normal file
130
libnautilus-private/nautilus-theme.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-theme.c: theme framework with xml-based theme definition files
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
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.
|
||||
|
||||
Author: Andy Hertzfeld <andy@eazel.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <parser.h>
|
||||
#include <xmlmemory.h>
|
||||
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
|
||||
#include "nautilus-file.h"
|
||||
#include "nautilus-file-utilities.h"
|
||||
#include "nautilus-metadata.h"
|
||||
#include "nautilus-string.h"
|
||||
#include "nautilus-xml-extensions.h"
|
||||
#include "nautilus-global-preferences.h"
|
||||
#include "nautilus-preferences.h"
|
||||
|
||||
#include "nautilus-theme.h"
|
||||
|
||||
/* static globals to hold the last accessed theme file */
|
||||
static char *last_theme_name = NULL;
|
||||
static xmlDocPtr last_theme_document = NULL;
|
||||
|
||||
/* return the current theme by asking the preferences machinery */
|
||||
char *
|
||||
nautilus_theme_get_theme(void)
|
||||
{
|
||||
return nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
}
|
||||
|
||||
/* set the current theme */
|
||||
void
|
||||
nautilus_theme_set_theme(const char *new_theme)
|
||||
{
|
||||
char *old_theme;
|
||||
|
||||
old_theme = nautilus_theme_get_theme();
|
||||
if (nautilus_strcmp (old_theme, new_theme)) {
|
||||
nautilus_preferences_set (NAUTILUS_PREFERENCES_THEME, new_theme);
|
||||
}
|
||||
g_free (old_theme);
|
||||
}
|
||||
|
||||
/* load and parse a theme file */
|
||||
static xmlDocPtr
|
||||
load_theme_document (const char * theme_name)
|
||||
{
|
||||
xmlDocPtr theme_document;
|
||||
char *theme_path, *temp_str;
|
||||
|
||||
/* formulate the theme path name */
|
||||
if (strcmp(theme_name, "default") == 0) {
|
||||
theme_path = nautilus_pixmap_file ("default.xml");
|
||||
} else {
|
||||
temp_str = g_strdup_printf("%s/%s.xml", theme_name, theme_name);
|
||||
theme_path = nautilus_pixmap_file (temp_str);
|
||||
g_free(temp_str);
|
||||
}
|
||||
|
||||
/* load and parse the theme file */
|
||||
theme_document = xmlParseFile(theme_path);
|
||||
g_free(theme_path);
|
||||
|
||||
return theme_document;
|
||||
}
|
||||
|
||||
/* fetch data from the current theme. Cache the last theme file as a parsed xml document */
|
||||
char *
|
||||
nautilus_theme_get_theme_data(const char *resource_name, const char *property_name)
|
||||
{
|
||||
char *theme_name, *temp_str;
|
||||
char *theme_data;
|
||||
|
||||
xmlDocPtr theme_document;
|
||||
xmlNodePtr resource_node;
|
||||
|
||||
/* fetch the current theme name */
|
||||
theme_data = NULL;
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
if (nautilus_strcmp (theme_name, last_theme_name) == 0) {
|
||||
theme_document = last_theme_document;
|
||||
} else {
|
||||
/* release the old saved data, since the theme changed */
|
||||
if (last_theme_document)
|
||||
xmlFreeDoc (last_theme_document);
|
||||
g_free (last_theme_name);
|
||||
|
||||
last_theme_name = g_strdup (theme_name);
|
||||
last_theme_document = load_theme_document (theme_name);
|
||||
theme_document = last_theme_document;
|
||||
}
|
||||
|
||||
if (theme_document != NULL) {
|
||||
/* fetch the resource node */
|
||||
|
||||
resource_node = nautilus_xml_get_child_by_name(xmlDocGetRootElement (theme_document), resource_name);
|
||||
if (resource_node) {
|
||||
temp_str = xmlGetProp(resource_node, property_name);
|
||||
if (temp_str)
|
||||
theme_data = g_strdup (temp_str);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(theme_name);
|
||||
|
||||
return theme_data;
|
||||
}
|
39
libnautilus-private/nautilus-theme.h
Normal file
39
libnautilus-private/nautilus-theme.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
||||
|
||||
nautilus-theme.h: theme framework with xml-based theme definition files
|
||||
|
||||
Copyright (C) 2000 Eazel, Inc.
|
||||
|
||||
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.
|
||||
|
||||
Authors: Andy Hertzfeld <andy@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_THEME_H
|
||||
#define NAUTILUS_THEME_H
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
/* get and set the current theme */
|
||||
char *nautilus_theme_get_theme(void);
|
||||
void nautilus_theme_set_theme(const char *new_theme);
|
||||
|
||||
/* fetch data from the current theme */
|
||||
char *nautilus_theme_get_theme_data(const char *resource_name, const char *property_name);
|
||||
|
||||
|
||||
#endif /* NAUTILUS_THEME_H */
|
|
@ -50,8 +50,8 @@
|
|||
#include <libnautilus-extensions/nautilus-string.h>
|
||||
#include <libnautilus-extensions/nautilus-mime-actions.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
#include <libnautilus-extensions/nautilus-theme.h>
|
||||
#include <libnautilus-extensions/nautilus-view-identifier.h>
|
||||
#include <libnautilus-extensions/nautilus-xml-extensions.h>
|
||||
|
||||
#include "nautilus-sidebar-tabs.h"
|
||||
#include "nautilus-sidebar-title.h"
|
||||
|
@ -450,55 +450,28 @@ nautilus_sidebar_new (void)
|
|||
static void
|
||||
nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
||||
{
|
||||
char *theme_name, *theme_path, *temp_str;
|
||||
xmlDocPtr document;
|
||||
xmlNodePtr sidebar_node;
|
||||
char *background_color, *background_image;
|
||||
|
||||
/* fetch the current theme name */
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
background_color = nautilus_theme_get_theme_data ("sidebar", NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR);
|
||||
background_image = nautilus_theme_get_theme_data ("sidebar", NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE);
|
||||
|
||||
/* formulate the theme path name */
|
||||
if (strcmp(theme_name, "default") == 0) {
|
||||
theme_path = nautilus_pixmap_file ("default.xml");
|
||||
} else {
|
||||
temp_str = g_strdup_printf("%s/%s.xml", theme_name, theme_name);
|
||||
theme_path = nautilus_pixmap_file (temp_str);
|
||||
g_free(temp_str);
|
||||
g_free(sidebar->details->default_background_color);
|
||||
sidebar->details->default_background_color = NULL;
|
||||
g_free(sidebar->details->default_background_image);
|
||||
sidebar->details->default_background_image = NULL;
|
||||
|
||||
if (background_color && strlen(background_color)) {
|
||||
sidebar->details->default_background_color = g_strdup(background_color);
|
||||
}
|
||||
|
||||
/* load and parse the theme file */
|
||||
document = xmlParseFile(theme_path);
|
||||
g_free(theme_path);
|
||||
|
||||
if (document != NULL) {
|
||||
/* fetch the sidebar node */
|
||||
|
||||
sidebar_node = nautilus_xml_get_child_by_name(xmlDocGetRootElement (document), "sidebar");
|
||||
if (sidebar_node) {
|
||||
/* set up the default background color */
|
||||
g_free(sidebar->details->default_background_color);
|
||||
sidebar->details->default_background_color = NULL;
|
||||
g_free(sidebar->details->default_background_image);
|
||||
sidebar->details->default_background_image = NULL;
|
||||
|
||||
temp_str = xmlGetProp(sidebar_node, NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR);
|
||||
if (temp_str && strlen(temp_str)) {
|
||||
sidebar->details->default_background_color = g_strdup(temp_str);
|
||||
}
|
||||
|
||||
/* set up the default background image */
|
||||
/* set up the default background image */
|
||||
|
||||
temp_str = xmlGetProp(sidebar_node, NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE);
|
||||
if (temp_str && strlen(temp_str)) {
|
||||
sidebar->details->default_background_image = g_strdup(temp_str);
|
||||
}
|
||||
if (background_image && strlen(background_image)) {
|
||||
sidebar->details->default_background_image = g_strdup(background_image);
|
||||
}
|
||||
|
||||
/* set up the sidebar tab info */
|
||||
}
|
||||
xmlFreeDoc(document);
|
||||
}
|
||||
|
||||
g_free(theme_name);
|
||||
g_free (background_color);
|
||||
g_free (background_image);
|
||||
}
|
||||
|
||||
/* handler for handling theme changes */
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
#include <libnautilus-extensions/nautilus-string.h>
|
||||
#include <libnautilus-extensions/nautilus-mime-actions.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.h>
|
||||
#include <libnautilus-extensions/nautilus-theme.h>
|
||||
#include <libnautilus-extensions/nautilus-view-identifier.h>
|
||||
#include <libnautilus-extensions/nautilus-xml-extensions.h>
|
||||
|
||||
#include "nautilus-sidebar-tabs.h"
|
||||
#include "nautilus-sidebar-title.h"
|
||||
|
@ -450,55 +450,28 @@ nautilus_sidebar_new (void)
|
|||
static void
|
||||
nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
||||
{
|
||||
char *theme_name, *theme_path, *temp_str;
|
||||
xmlDocPtr document;
|
||||
xmlNodePtr sidebar_node;
|
||||
char *background_color, *background_image;
|
||||
|
||||
/* fetch the current theme name */
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
background_color = nautilus_theme_get_theme_data ("sidebar", NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR);
|
||||
background_image = nautilus_theme_get_theme_data ("sidebar", NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE);
|
||||
|
||||
/* formulate the theme path name */
|
||||
if (strcmp(theme_name, "default") == 0) {
|
||||
theme_path = nautilus_pixmap_file ("default.xml");
|
||||
} else {
|
||||
temp_str = g_strdup_printf("%s/%s.xml", theme_name, theme_name);
|
||||
theme_path = nautilus_pixmap_file (temp_str);
|
||||
g_free(temp_str);
|
||||
g_free(sidebar->details->default_background_color);
|
||||
sidebar->details->default_background_color = NULL;
|
||||
g_free(sidebar->details->default_background_image);
|
||||
sidebar->details->default_background_image = NULL;
|
||||
|
||||
if (background_color && strlen(background_color)) {
|
||||
sidebar->details->default_background_color = g_strdup(background_color);
|
||||
}
|
||||
|
||||
/* load and parse the theme file */
|
||||
document = xmlParseFile(theme_path);
|
||||
g_free(theme_path);
|
||||
|
||||
if (document != NULL) {
|
||||
/* fetch the sidebar node */
|
||||
|
||||
sidebar_node = nautilus_xml_get_child_by_name(xmlDocGetRootElement (document), "sidebar");
|
||||
if (sidebar_node) {
|
||||
/* set up the default background color */
|
||||
g_free(sidebar->details->default_background_color);
|
||||
sidebar->details->default_background_color = NULL;
|
||||
g_free(sidebar->details->default_background_image);
|
||||
sidebar->details->default_background_image = NULL;
|
||||
|
||||
temp_str = xmlGetProp(sidebar_node, NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR);
|
||||
if (temp_str && strlen(temp_str)) {
|
||||
sidebar->details->default_background_color = g_strdup(temp_str);
|
||||
}
|
||||
|
||||
/* set up the default background image */
|
||||
/* set up the default background image */
|
||||
|
||||
temp_str = xmlGetProp(sidebar_node, NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE);
|
||||
if (temp_str && strlen(temp_str)) {
|
||||
sidebar->details->default_background_image = g_strdup(temp_str);
|
||||
}
|
||||
if (background_image && strlen(background_image)) {
|
||||
sidebar->details->default_background_image = g_strdup(background_image);
|
||||
}
|
||||
|
||||
/* set up the sidebar tab info */
|
||||
}
|
||||
xmlFreeDoc(document);
|
||||
}
|
||||
|
||||
g_free(theme_name);
|
||||
g_free (background_color);
|
||||
g_free (background_image);
|
||||
}
|
||||
|
||||
/* handler for handling theme changes */
|
||||
|
|
Loading…
Reference in a new issue