mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 10:45:41 +00:00
implemented an xml-based general theme mechanism, and used it for the
implemented an xml-based general theme mechanism, and used it for the sidebar backgrounds, which isn't quite working yet. Added xml files to our themes.
This commit is contained in:
parent
173c750acb
commit
a59d6685a6
34
ChangeLog
34
ChangeLog
|
@ -1,3 +1,37 @@
|
|||
2000-06-26 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
added xml based theme mechanism and used it for the sidebar background,
|
||||
which isn't entirely working yet.
|
||||
|
||||
* icons/Makefile.am:
|
||||
* icons/default.xml:
|
||||
* icons/eazel/Makefile.am:
|
||||
* icons/eazel/eazel.xml:
|
||||
* icons/vector/Makefile.am:
|
||||
* icons/vector/vector.xml:
|
||||
new xml-based theme files
|
||||
* libnautilus-extensions/nautilus-global-preferences.c,h:
|
||||
(global_preferences_create_dialog),
|
||||
(global_preferences_register_for_ui):
|
||||
changed "icon_theme" preference to general "theme"
|
||||
* libnautilus-extensions/nautilus-icon-factory.c:
|
||||
(nautilus_get_current_icon_factory),
|
||||
(nautilus_icon_factory_destroy), (icon_theme_changed_callback):
|
||||
changed from "icon_theme" to "theme"
|
||||
* libnautilus-extensions/nautilus-preferences-item.c,h:
|
||||
(preferences_item_construct), (preferences_item_create_theme):
|
||||
changed from "icon_theme" to "theme"
|
||||
* libnautilus-extensions/nautilus-xml-extensions.c,h:
|
||||
(nautilus_xml_get_child_by_name):
|
||||
added a routine to access child nodes
|
||||
* src/nautilus-sidebar.c: (nautilus_sidebar_initialize),
|
||||
(nautilus_sidebar_destroy), (nautilus_sidebar_read_theme),
|
||||
(nautilus_sidebar_theme_changed),
|
||||
(nautilus_sidebar_background_changed),
|
||||
(nautilus_sidebar_update_info):
|
||||
made the sidebar get its default values from an xml-based theme file, and reload
|
||||
them when the theme changes
|
||||
|
||||
2000-06-25 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
* libnautilus-extensions/nautilus-link.c:
|
||||
|
|
|
@ -11,6 +11,7 @@ icon_DATA =\
|
|||
colors.png \
|
||||
computer.png \
|
||||
computer.svg \
|
||||
default.xml \
|
||||
eazel-logo.gif \
|
||||
emblem-certified.gif \
|
||||
emblem-changed.gif \
|
||||
|
|
5
icons/default.xml
Normal file
5
icons/default.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<theme name="default">
|
||||
<sidebar SIDEBAR_BACKGROUND_COLOR="rgb:DDDD/DDDD/FFFF"/>
|
||||
<iconcontainer BACKGROUND_COLOR="rgb:FFFF/FFFF/FFFF"/>
|
||||
</theme>
|
|
@ -2,6 +2,7 @@ eazeldir = $(datadir)/pixmaps/nautilus/eazel
|
|||
|
||||
eazel_DATA = \
|
||||
Back.png \
|
||||
eazel.xml \
|
||||
Forward.png \
|
||||
Home.png \
|
||||
i-directory.png \
|
||||
|
|
5
icons/eazel/eazel.xml
Normal file
5
icons/eazel/eazel.xml
Normal file
|
@ -0,0 +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"/>
|
||||
</theme>
|
|
@ -4,6 +4,8 @@ vector_DATA = \
|
|||
i-directory.svg \
|
||||
i-directory-accept.svg \
|
||||
i-regular.svg \
|
||||
i-regular.xml
|
||||
i-regular.xml \
|
||||
vector.xml
|
||||
|
||||
|
||||
EXTRA_DIST = $(vector_DATA)
|
||||
|
|
5
icons/vector/vector.xml
Normal file
5
icons/vector/vector.xml
Normal file
|
@ -0,0 +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"/>
|
||||
</theme>
|
|
@ -200,8 +200,8 @@ global_preferences_create_dialog (void)
|
|||
|
||||
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
|
||||
1,
|
||||
NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_ICON_THEME);
|
||||
NAUTILUS_PREFERENCES_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_THEME);
|
||||
|
||||
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), "Fonts");
|
||||
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
|
||||
|
@ -543,7 +543,7 @@ global_preferences_register_for_ui (void)
|
|||
FALSE,
|
||||
FALSE);
|
||||
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_THEME,
|
||||
"theme for file icons: ",
|
||||
"default",
|
||||
"default",
|
||||
|
|
|
@ -64,7 +64,7 @@ BEGIN_GNOME_DECLS
|
|||
|
||||
/* themes */
|
||||
#define NAUTILUS_PREFERENCES_TOOLBAR_ICON_THEME "preferences/toolbar_icon_theme"
|
||||
#define NAUTILUS_PREFERENCES_ICON_THEME "preferences/icon_theme"
|
||||
#define NAUTILUS_PREFERENCES_THEME "preferences/theme"
|
||||
|
||||
/* File Indexing */
|
||||
#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search"
|
||||
|
|
|
@ -240,14 +240,14 @@ nautilus_get_current_icon_factory (void)
|
|||
if (global_icon_factory == NULL) {
|
||||
char *theme_preference;
|
||||
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME,
|
||||
DEFAULT_ICON_THEME);
|
||||
g_assert (theme_preference != NULL);
|
||||
|
||||
global_icon_factory = nautilus_icon_factory_new (theme_preference);
|
||||
g_free (theme_preference);
|
||||
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
icon_theme_changed_callback,
|
||||
NULL);
|
||||
|
||||
|
@ -343,7 +343,7 @@ nautilus_icon_factory_clear (void)
|
|||
static void
|
||||
nautilus_icon_factory_destroy (NautilusIconFactory *factory)
|
||||
{
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
icon_theme_changed_callback,
|
||||
NULL);
|
||||
|
||||
|
@ -721,7 +721,7 @@ icon_theme_changed_callback (gpointer user_data)
|
|||
{
|
||||
char *theme_preference;
|
||||
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME,
|
||||
DEFAULT_ICON_THEME);
|
||||
|
||||
g_assert (theme_preference != NULL);
|
||||
|
|
|
@ -88,7 +88,7 @@ static void preferences_item_create_editable_string (NautilusPreferencesItem
|
|||
const NautilusPreference *prefrence);
|
||||
static void preferences_item_create_font_family (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *prefrence);
|
||||
static void preferences_item_create_icon_theme (NautilusPreferencesItem *item,
|
||||
static void preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
static void preferences_item_create_toolbar_icon_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
|
@ -279,8 +279,8 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
preferences_item_create_font_family (item, preference);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_ICON_THEME:
|
||||
preferences_item_create_icon_theme (item, preference);
|
||||
case NAUTILUS_PREFERENCE_ITEM_THEME:
|
||||
preferences_item_create_theme (item, preference);
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING:
|
||||
preferences_item_create_editable_string (item, preference);
|
||||
|
@ -532,7 +532,7 @@ add_icon_themes(NautilusStringList *theme_list, char *required_file)
|
|||
}
|
||||
|
||||
static void
|
||||
preferences_item_create_icon_theme (NautilusPreferencesItem *item,
|
||||
preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
{
|
||||
char *description;
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef enum
|
|||
NAUTILUS_PREFERENCE_ITEM_BOOLEAN,
|
||||
NAUTILUS_PREFERENCE_ITEM_ENUM,
|
||||
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY,
|
||||
NAUTILUS_PREFERENCE_ITEM_ICON_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING,
|
||||
NAUTILUS_PREFERENCE_ITEM_TOOLBAR_ICON_THEME
|
||||
} NautilusPreferencesItemType;
|
||||
|
|
|
@ -71,6 +71,26 @@ nautilus_xml_get_child_by_name_and_property (xmlNodePtr parent,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* return a child of the passed-in node with a matching name */
|
||||
|
||||
xmlNodePtr
|
||||
nautilus_xml_get_child_by_name (xmlNodePtr parent,
|
||||
const char *child_name)
|
||||
{
|
||||
xmlNodePtr child;
|
||||
|
||||
if (parent == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (child = nautilus_xml_get_children (parent); child != NULL; child = child->next) {
|
||||
if (strcmp (child->name, child_name) == 0) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
xmlNodePtr
|
||||
nautilus_xml_get_root_child_by_name_and_property (xmlDocPtr document,
|
||||
const char *child_name,
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
xmlNodePtr nautilus_xml_get_children (xmlNodePtr parent);
|
||||
xmlNodePtr nautilus_xml_get_root_children (xmlDocPtr document);
|
||||
xmlNodePtr nautilus_xml_get_child_by_name (xmlNodePtr parent,
|
||||
const char *child_name);
|
||||
xmlNodePtr nautilus_xml_get_child_by_name_and_property (xmlNodePtr parent,
|
||||
const char *child_name,
|
||||
const char *property_name,
|
||||
|
|
|
@ -200,8 +200,8 @@ global_preferences_create_dialog (void)
|
|||
|
||||
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
|
||||
1,
|
||||
NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_ICON_THEME);
|
||||
NAUTILUS_PREFERENCES_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_THEME);
|
||||
|
||||
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (appearance_pane), "Fonts");
|
||||
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (appearance_pane),
|
||||
|
@ -543,7 +543,7 @@ global_preferences_register_for_ui (void)
|
|||
FALSE,
|
||||
FALSE);
|
||||
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_THEME,
|
||||
"theme for file icons: ",
|
||||
"default",
|
||||
"default",
|
||||
|
|
|
@ -64,7 +64,7 @@ BEGIN_GNOME_DECLS
|
|||
|
||||
/* themes */
|
||||
#define NAUTILUS_PREFERENCES_TOOLBAR_ICON_THEME "preferences/toolbar_icon_theme"
|
||||
#define NAUTILUS_PREFERENCES_ICON_THEME "preferences/icon_theme"
|
||||
#define NAUTILUS_PREFERENCES_THEME "preferences/theme"
|
||||
|
||||
/* File Indexing */
|
||||
#define NAUTILUS_PREFERENCES_SEARCH_METHOD "preferences/also_do_slow_search"
|
||||
|
|
|
@ -240,14 +240,14 @@ nautilus_get_current_icon_factory (void)
|
|||
if (global_icon_factory == NULL) {
|
||||
char *theme_preference;
|
||||
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME,
|
||||
DEFAULT_ICON_THEME);
|
||||
g_assert (theme_preference != NULL);
|
||||
|
||||
global_icon_factory = nautilus_icon_factory_new (theme_preference);
|
||||
g_free (theme_preference);
|
||||
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
icon_theme_changed_callback,
|
||||
NULL);
|
||||
|
||||
|
@ -343,7 +343,7 @@ nautilus_icon_factory_clear (void)
|
|||
static void
|
||||
nautilus_icon_factory_destroy (NautilusIconFactory *factory)
|
||||
{
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
icon_theme_changed_callback,
|
||||
NULL);
|
||||
|
||||
|
@ -721,7 +721,7 @@ icon_theme_changed_callback (gpointer user_data)
|
|||
{
|
||||
char *theme_preference;
|
||||
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_ICON_THEME,
|
||||
theme_preference = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME,
|
||||
DEFAULT_ICON_THEME);
|
||||
|
||||
g_assert (theme_preference != NULL);
|
||||
|
|
|
@ -88,7 +88,7 @@ static void preferences_item_create_editable_string (NautilusPreferencesItem
|
|||
const NautilusPreference *prefrence);
|
||||
static void preferences_item_create_font_family (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *prefrence);
|
||||
static void preferences_item_create_icon_theme (NautilusPreferencesItem *item,
|
||||
static void preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
static void preferences_item_create_toolbar_icon_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference);
|
||||
|
@ -279,8 +279,8 @@ preferences_item_construct (NautilusPreferencesItem *item,
|
|||
preferences_item_create_font_family (item, preference);
|
||||
break;
|
||||
|
||||
case NAUTILUS_PREFERENCE_ITEM_ICON_THEME:
|
||||
preferences_item_create_icon_theme (item, preference);
|
||||
case NAUTILUS_PREFERENCE_ITEM_THEME:
|
||||
preferences_item_create_theme (item, preference);
|
||||
break;
|
||||
case NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING:
|
||||
preferences_item_create_editable_string (item, preference);
|
||||
|
@ -532,7 +532,7 @@ add_icon_themes(NautilusStringList *theme_list, char *required_file)
|
|||
}
|
||||
|
||||
static void
|
||||
preferences_item_create_icon_theme (NautilusPreferencesItem *item,
|
||||
preferences_item_create_theme (NautilusPreferencesItem *item,
|
||||
const NautilusPreference *preference)
|
||||
{
|
||||
char *description;
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef enum
|
|||
NAUTILUS_PREFERENCE_ITEM_BOOLEAN,
|
||||
NAUTILUS_PREFERENCE_ITEM_ENUM,
|
||||
NAUTILUS_PREFERENCE_ITEM_FONT_FAMILY,
|
||||
NAUTILUS_PREFERENCE_ITEM_ICON_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_THEME,
|
||||
NAUTILUS_PREFERENCE_ITEM_EDITABLE_STRING,
|
||||
NAUTILUS_PREFERENCE_ITEM_TOOLBAR_ICON_THEME
|
||||
} NautilusPreferencesItemType;
|
||||
|
|
|
@ -71,6 +71,26 @@ nautilus_xml_get_child_by_name_and_property (xmlNodePtr parent,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* return a child of the passed-in node with a matching name */
|
||||
|
||||
xmlNodePtr
|
||||
nautilus_xml_get_child_by_name (xmlNodePtr parent,
|
||||
const char *child_name)
|
||||
{
|
||||
xmlNodePtr child;
|
||||
|
||||
if (parent == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (child = nautilus_xml_get_children (parent); child != NULL; child = child->next) {
|
||||
if (strcmp (child->name, child_name) == 0) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
xmlNodePtr
|
||||
nautilus_xml_get_root_child_by_name_and_property (xmlDocPtr document,
|
||||
const char *child_name,
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
xmlNodePtr nautilus_xml_get_children (xmlNodePtr parent);
|
||||
xmlNodePtr nautilus_xml_get_root_children (xmlDocPtr document);
|
||||
xmlNodePtr nautilus_xml_get_child_by_name (xmlNodePtr parent,
|
||||
const char *child_name);
|
||||
xmlNodePtr nautilus_xml_get_child_by_name_and_property (xmlNodePtr parent,
|
||||
const char *child_name,
|
||||
const char *property_name,
|
||||
|
|
|
@ -34,10 +34,12 @@
|
|||
#include <libgnomevfs/gnome-vfs-uri.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <liboaf/liboaf.h>
|
||||
#include <parser.h>
|
||||
|
||||
#include <libnautilus-extensions/nautilus-background.h>
|
||||
#include <libnautilus-extensions/nautilus-directory.h>
|
||||
#include <libnautilus-extensions/nautilus-file.h>
|
||||
#include <libnautilus-extensions/nautilus-file-utilities.h>
|
||||
#include <libnautilus-extensions/nautilus-glib-extensions.h>
|
||||
#include <libnautilus-extensions/nautilus-global-preferences.h>
|
||||
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
|
||||
|
@ -49,6 +51,7 @@
|
|||
#include <libnautilus-extensions/nautilus-mime-actions.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.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"
|
||||
|
@ -64,6 +67,8 @@ struct NautilusSidebarDetails {
|
|||
GtkVBox *button_box;
|
||||
gboolean has_buttons;
|
||||
char *uri;
|
||||
char *default_background_color;
|
||||
char *default_background_image;
|
||||
int selected_index;
|
||||
NautilusDirectory *directory;
|
||||
int background_connection;
|
||||
|
@ -89,8 +94,11 @@ static void nautilus_sidebar_drag_data_received (GtkWidget *widget,
|
|||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time);
|
||||
static void nautilus_sidebar_read_theme (NautilusSidebar *sidebar);
|
||||
|
||||
static void nautilus_sidebar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void nautilus_sidebar_theme_changed (gpointer user_data);
|
||||
static void nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
||||
const char *title);
|
||||
static void nautilus_sidebar_update_buttons (NautilusSidebar *sidebar);
|
||||
|
@ -98,7 +106,6 @@ static void add_command_buttons (NautilusSidebar *sidebar,
|
|||
GList *application_list);
|
||||
|
||||
/* FIXME bug 1245: hardwired sizes */
|
||||
#define DEFAULT_BACKGROUND_COLOR "rgb:DDDD/DDDD/FFFF"
|
||||
#define DEFAULT_TAB_COLOR "rgb:9999/9999/9999"
|
||||
|
||||
#define SIDEBAR_MINIMUM_WIDTH 1
|
||||
|
@ -205,7 +212,10 @@ nautilus_sidebar_initialize (GtkObject *object)
|
|||
|
||||
/* set the minimum size of the sidebar */
|
||||
gtk_widget_set_usize (widget, SIDEBAR_MINIMUM_WIDTH, SIDEBAR_MINIMUM_HEIGHT);
|
||||
|
||||
|
||||
/* load the default background from the current theme */
|
||||
nautilus_sidebar_read_theme(sidebar);
|
||||
|
||||
/* create the container box */
|
||||
sidebar->details->container = GTK_VBOX (gtk_vbox_new (FALSE, 0));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (sidebar->details->container), 0);
|
||||
|
@ -245,6 +255,9 @@ nautilus_sidebar_initialize (GtkObject *object)
|
|||
/* allocate and install the command button container */
|
||||
make_button_box (sidebar);
|
||||
|
||||
/* add a callback for when the theme changes */
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, nautilus_sidebar_theme_changed, sidebar);
|
||||
|
||||
/* prepare ourselves to receive dropped objects */
|
||||
gtk_drag_dest_set (GTK_WIDGET (sidebar),
|
||||
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
|
||||
|
@ -264,7 +277,14 @@ nautilus_sidebar_destroy (GtkObject *object)
|
|||
nautilus_directory_unref (sidebar->details->directory);
|
||||
|
||||
g_free (sidebar->details->uri);
|
||||
g_free (sidebar->details->default_background_color);
|
||||
g_free (sidebar->details->default_background_image);
|
||||
|
||||
g_free (sidebar->details);
|
||||
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
nautilus_sidebar_theme_changed,
|
||||
sidebar);
|
||||
|
||||
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
|
||||
}
|
||||
|
@ -364,7 +384,7 @@ nautilus_sidebar_add_panel_items(NautilusSidebar *sidebar, GtkWidget *menu)
|
|||
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
|
||||
/* create the context menu */
|
||||
GtkWidget *
|
||||
nautilus_sidebar_create_context_menu (NautilusSidebar *sidebar)
|
||||
|
@ -402,6 +422,76 @@ nautilus_sidebar_new (void)
|
|||
return NAUTILUS_SIDEBAR (gtk_type_new (nautilus_sidebar_get_type ()));
|
||||
}
|
||||
|
||||
/* read the theme file and set up the default backgrounds and images accordingly */
|
||||
static void
|
||||
nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
||||
{
|
||||
char *theme_name, *theme_path, *temp_str;
|
||||
xmlDocPtr document;
|
||||
xmlNodePtr sidebar_node;
|
||||
|
||||
/* fetch the current theme name */
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
|
||||
/* 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 */
|
||||
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 */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* set up the sidebar tab info */
|
||||
}
|
||||
xmlFreeDoc(document);
|
||||
}
|
||||
|
||||
g_free(theme_name);
|
||||
}
|
||||
|
||||
/* handler for handling theme changes */
|
||||
|
||||
static void
|
||||
nautilus_sidebar_theme_changed (gpointer user_data)
|
||||
{
|
||||
NautilusSidebar *sidebar;
|
||||
|
||||
sidebar = NAUTILUS_SIDEBAR(user_data);
|
||||
nautilus_sidebar_read_theme(sidebar);
|
||||
nautilus_sidebar_update_info(sidebar, NULL);
|
||||
gtk_widget_queue_draw(GTK_WIDGET(sidebar)) ;
|
||||
}
|
||||
|
||||
/* hit testing */
|
||||
|
||||
static SidebarPart
|
||||
hit_test (NautilusSidebar *sidebar,
|
||||
int x, int y)
|
||||
|
@ -859,14 +949,14 @@ nautilus_sidebar_background_changed (NautilusSidebar *sidebar)
|
|||
color_spec = nautilus_background_get_color (background);
|
||||
nautilus_directory_set_metadata (sidebar->details->directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR,
|
||||
DEFAULT_BACKGROUND_COLOR,
|
||||
sidebar->details->default_background_color,
|
||||
color_spec);
|
||||
g_free (color_spec);
|
||||
|
||||
image = nautilus_background_get_tile_image_uri (background);
|
||||
nautilus_directory_set_metadata (sidebar->details->directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE,
|
||||
NULL,
|
||||
sidebar->details->default_background_image,
|
||||
image);
|
||||
g_free (image);
|
||||
}
|
||||
|
@ -1091,7 +1181,7 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
NautilusDirectory *directory;
|
||||
NautilusBackground *background;
|
||||
char *background_color, *color_spec;
|
||||
char *background_image;
|
||||
char *background_image, *temp_str;
|
||||
|
||||
directory = nautilus_directory_get (sidebar->details->uri);
|
||||
nautilus_directory_unref (sidebar->details->directory);
|
||||
|
@ -1110,10 +1200,20 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
/* Set up the background color and image from the metadata. */
|
||||
background_color = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR,
|
||||
DEFAULT_BACKGROUND_COLOR);
|
||||
sidebar->details->default_background_color);
|
||||
|
||||
background_image = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE,
|
||||
NULL);
|
||||
sidebar->details->default_background_image);
|
||||
|
||||
if (background_image && !nautilus_str_has_prefix (background_image, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
background_image);
|
||||
g_free (background_image);
|
||||
background_image = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
|
||||
nautilus_background_set_color (background, background_color);
|
||||
g_free (background_color);
|
||||
|
|
|
@ -34,10 +34,12 @@
|
|||
#include <libgnomevfs/gnome-vfs-uri.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <liboaf/liboaf.h>
|
||||
#include <parser.h>
|
||||
|
||||
#include <libnautilus-extensions/nautilus-background.h>
|
||||
#include <libnautilus-extensions/nautilus-directory.h>
|
||||
#include <libnautilus-extensions/nautilus-file.h>
|
||||
#include <libnautilus-extensions/nautilus-file-utilities.h>
|
||||
#include <libnautilus-extensions/nautilus-glib-extensions.h>
|
||||
#include <libnautilus-extensions/nautilus-global-preferences.h>
|
||||
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
|
||||
|
@ -49,6 +51,7 @@
|
|||
#include <libnautilus-extensions/nautilus-mime-actions.h>
|
||||
#include <libnautilus-extensions/nautilus-preferences.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"
|
||||
|
@ -64,6 +67,8 @@ struct NautilusSidebarDetails {
|
|||
GtkVBox *button_box;
|
||||
gboolean has_buttons;
|
||||
char *uri;
|
||||
char *default_background_color;
|
||||
char *default_background_image;
|
||||
int selected_index;
|
||||
NautilusDirectory *directory;
|
||||
int background_connection;
|
||||
|
@ -89,8 +94,11 @@ static void nautilus_sidebar_drag_data_received (GtkWidget *widget,
|
|||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time);
|
||||
static void nautilus_sidebar_read_theme (NautilusSidebar *sidebar);
|
||||
|
||||
static void nautilus_sidebar_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static void nautilus_sidebar_theme_changed (gpointer user_data);
|
||||
static void nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
||||
const char *title);
|
||||
static void nautilus_sidebar_update_buttons (NautilusSidebar *sidebar);
|
||||
|
@ -98,7 +106,6 @@ static void add_command_buttons (NautilusSidebar *sidebar,
|
|||
GList *application_list);
|
||||
|
||||
/* FIXME bug 1245: hardwired sizes */
|
||||
#define DEFAULT_BACKGROUND_COLOR "rgb:DDDD/DDDD/FFFF"
|
||||
#define DEFAULT_TAB_COLOR "rgb:9999/9999/9999"
|
||||
|
||||
#define SIDEBAR_MINIMUM_WIDTH 1
|
||||
|
@ -205,7 +212,10 @@ nautilus_sidebar_initialize (GtkObject *object)
|
|||
|
||||
/* set the minimum size of the sidebar */
|
||||
gtk_widget_set_usize (widget, SIDEBAR_MINIMUM_WIDTH, SIDEBAR_MINIMUM_HEIGHT);
|
||||
|
||||
|
||||
/* load the default background from the current theme */
|
||||
nautilus_sidebar_read_theme(sidebar);
|
||||
|
||||
/* create the container box */
|
||||
sidebar->details->container = GTK_VBOX (gtk_vbox_new (FALSE, 0));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (sidebar->details->container), 0);
|
||||
|
@ -245,6 +255,9 @@ nautilus_sidebar_initialize (GtkObject *object)
|
|||
/* allocate and install the command button container */
|
||||
make_button_box (sidebar);
|
||||
|
||||
/* add a callback for when the theme changes */
|
||||
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, nautilus_sidebar_theme_changed, sidebar);
|
||||
|
||||
/* prepare ourselves to receive dropped objects */
|
||||
gtk_drag_dest_set (GTK_WIDGET (sidebar),
|
||||
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
|
||||
|
@ -264,7 +277,14 @@ nautilus_sidebar_destroy (GtkObject *object)
|
|||
nautilus_directory_unref (sidebar->details->directory);
|
||||
|
||||
g_free (sidebar->details->uri);
|
||||
g_free (sidebar->details->default_background_color);
|
||||
g_free (sidebar->details->default_background_image);
|
||||
|
||||
g_free (sidebar->details);
|
||||
|
||||
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
|
||||
nautilus_sidebar_theme_changed,
|
||||
sidebar);
|
||||
|
||||
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
|
||||
}
|
||||
|
@ -364,7 +384,7 @@ nautilus_sidebar_add_panel_items(NautilusSidebar *sidebar, GtkWidget *menu)
|
|||
|
||||
CORBA_exception_free (&ev);
|
||||
}
|
||||
|
||||
|
||||
/* create the context menu */
|
||||
GtkWidget *
|
||||
nautilus_sidebar_create_context_menu (NautilusSidebar *sidebar)
|
||||
|
@ -402,6 +422,76 @@ nautilus_sidebar_new (void)
|
|||
return NAUTILUS_SIDEBAR (gtk_type_new (nautilus_sidebar_get_type ()));
|
||||
}
|
||||
|
||||
/* read the theme file and set up the default backgrounds and images accordingly */
|
||||
static void
|
||||
nautilus_sidebar_read_theme (NautilusSidebar *sidebar)
|
||||
{
|
||||
char *theme_name, *theme_path, *temp_str;
|
||||
xmlDocPtr document;
|
||||
xmlNodePtr sidebar_node;
|
||||
|
||||
/* fetch the current theme name */
|
||||
theme_name = nautilus_preferences_get (NAUTILUS_PREFERENCES_THEME, "default");
|
||||
|
||||
/* 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 */
|
||||
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 */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* set up the sidebar tab info */
|
||||
}
|
||||
xmlFreeDoc(document);
|
||||
}
|
||||
|
||||
g_free(theme_name);
|
||||
}
|
||||
|
||||
/* handler for handling theme changes */
|
||||
|
||||
static void
|
||||
nautilus_sidebar_theme_changed (gpointer user_data)
|
||||
{
|
||||
NautilusSidebar *sidebar;
|
||||
|
||||
sidebar = NAUTILUS_SIDEBAR(user_data);
|
||||
nautilus_sidebar_read_theme(sidebar);
|
||||
nautilus_sidebar_update_info(sidebar, NULL);
|
||||
gtk_widget_queue_draw(GTK_WIDGET(sidebar)) ;
|
||||
}
|
||||
|
||||
/* hit testing */
|
||||
|
||||
static SidebarPart
|
||||
hit_test (NautilusSidebar *sidebar,
|
||||
int x, int y)
|
||||
|
@ -859,14 +949,14 @@ nautilus_sidebar_background_changed (NautilusSidebar *sidebar)
|
|||
color_spec = nautilus_background_get_color (background);
|
||||
nautilus_directory_set_metadata (sidebar->details->directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR,
|
||||
DEFAULT_BACKGROUND_COLOR,
|
||||
sidebar->details->default_background_color,
|
||||
color_spec);
|
||||
g_free (color_spec);
|
||||
|
||||
image = nautilus_background_get_tile_image_uri (background);
|
||||
nautilus_directory_set_metadata (sidebar->details->directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE,
|
||||
NULL,
|
||||
sidebar->details->default_background_image,
|
||||
image);
|
||||
g_free (image);
|
||||
}
|
||||
|
@ -1091,7 +1181,7 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
NautilusDirectory *directory;
|
||||
NautilusBackground *background;
|
||||
char *background_color, *color_spec;
|
||||
char *background_image;
|
||||
char *background_image, *temp_str;
|
||||
|
||||
directory = nautilus_directory_get (sidebar->details->uri);
|
||||
nautilus_directory_unref (sidebar->details->directory);
|
||||
|
@ -1110,10 +1200,20 @@ nautilus_sidebar_update_info (NautilusSidebar *sidebar,
|
|||
/* Set up the background color and image from the metadata. */
|
||||
background_color = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR,
|
||||
DEFAULT_BACKGROUND_COLOR);
|
||||
sidebar->details->default_background_color);
|
||||
|
||||
background_image = nautilus_directory_get_metadata (directory,
|
||||
NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE,
|
||||
NULL);
|
||||
sidebar->details->default_background_image);
|
||||
|
||||
if (background_image && !nautilus_str_has_prefix (background_image, "file://")) {
|
||||
temp_str = g_strdup_printf ("%s/%s",
|
||||
NAUTILUS_DATADIR,
|
||||
background_image);
|
||||
g_free (background_image);
|
||||
background_image = nautilus_get_uri_from_local_path (temp_str);
|
||||
g_free (temp_str);
|
||||
}
|
||||
|
||||
nautilus_background_set_color (background, background_color);
|
||||
g_free (background_color);
|
||||
|
|
Loading…
Reference in a new issue