Commit 868dae3d authored by Dave Camp's avatar Dave Camp Committed by Dave Camp
Browse files

Add the desktop emblem. New functions. (nautilus_get_desktop_directory),

2003-05-16  Dave Camp  <dave@ximian.com>

	* libnautilus-private/nautilus-emblem-utils.c:
	(is_reserved_keyword), (nautilus_emblem_should_show_in_list):  Add
	the desktop emblem.
	* libnautilus-private/nautilus-file-utilities.c:
	(nautilus_get_desktop_directory_uri_no_create):
	(get_desktop_path): New functions.
	(nautilus_get_desktop_directory),
	(nautilus_get_desktop_directory_uri): Use get_desktop_path()
	* libnautilus-private/nautilus-file-utilities.h:
	* libnautilus-private/nautilus-file.h:
	* libnautilus-private/nautilus-file.c: (file_is_desktop),
	(get_automatic_emblems_as_integer),
	(prepend_automatic_emblem_names): Add a desktop emblem to the
	desktop directory.
parent 11df3df6
2003-05-16 Dave Camp <dave@ximian.com>
* libnautilus-private/nautilus-emblem-utils.c:
(is_reserved_keyword), (nautilus_emblem_should_show_in_list): Add
the desktop emblem.
* libnautilus-private/nautilus-file-utilities.c:
(nautilus_get_desktop_directory_uri_no_create):
(get_desktop_path): New functions.
(nautilus_get_desktop_directory),
(nautilus_get_desktop_directory_uri): Use get_desktop_path()
* libnautilus-private/nautilus-file-utilities.h:
* libnautilus-private/nautilus-file.h:
* libnautilus-private/nautilus-file.c: (file_is_desktop),
(get_automatic_emblems_as_integer),
(prepend_automatic_emblem_names): Add a desktop emblem to the
desktop directory.
2003-05-16 Alexander Larsson <alexl@redhat.com>
 
* src/nautilus-application.c (migrate_old_nautilus_files):
......
......@@ -44,6 +44,7 @@
#define EMBLEM_NAME_NOREAD "emblem-noread"
#define EMBLEM_NAME_NOWRITE "emblem-nowrite"
#define EMBLEM_NAME_NOTE "emblem-note"
#define EMBLEM_NAME_DESKTOP "emblem-desktop"
GList *
nautilus_emblem_list_availible (void)
......@@ -98,6 +99,9 @@ is_reserved_keyword (const char *keyword)
if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_NOTE) == 0) {
return TRUE;
}
if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_DESKTOP) == 0) {
return TRUE;
}
availible = nautilus_emblem_list_availible ();
icon_name = nautilus_emblem_get_icon_name_from_keyword (keyword);
......@@ -128,6 +132,9 @@ nautilus_emblem_should_show_in_list (const char *emblem)
if (strcmp (emblem, EMBLEM_NAME_NOTE) == 0) {
return FALSE;
}
if (strcmp (emblem, EMBLEM_NAME_DESKTOP) == 0) {
return FALSE;
}
return TRUE;
}
......
......@@ -90,6 +90,17 @@ nautilus_get_user_directory (void)
return user_directory;
}
static char *
get_desktop_path (void)
{
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
return g_strdup (g_get_home_dir());
} else {
return g_build_filename (g_get_home_dir (), DESKTOP_DIRECTORY_NAME, NULL);
}
}
/**
* nautilus_get_desktop_directory:
*
......@@ -101,11 +112,11 @@ char *
nautilus_get_desktop_directory (void)
{
char *desktop_directory;
desktop_directory = get_desktop_path ();
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
desktop_directory = g_strdup (g_get_home_dir());
} else {
desktop_directory = g_build_filename (g_get_home_dir (), DESKTOP_DIRECTORY_NAME, NULL);
/* Don't try to create a home directory */
if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
if (!g_file_test (desktop_directory, G_FILE_TEST_EXISTS)) {
mkdir (desktop_directory, DEFAULT_DESKTOP_DIRECTORY_MODE);
/* FIXME bugzilla.gnome.org 41286:
......@@ -142,6 +153,19 @@ nautilus_get_desktop_directory_uri (void)
return desktop_uri;
}
char *
nautilus_get_desktop_directory_uri_no_create (void)
{
char *desktop_path;
char *desktop_uri;
desktop_path = get_desktop_path ();
desktop_uri = gnome_vfs_get_uri_from_local_path (desktop_path);
g_free (desktop_path);
return desktop_uri;
}
/**
* nautilus_get_gmc_desktop_directory:
......
......@@ -40,6 +40,10 @@ char * nautilus_get_desktop_directory_uri (void);
char * nautilus_get_gmc_desktop_directory (void);
char * nautilus_get_pixmap_directory (void);
/* This function returns something that needs to be freed with g_free,
* is not NULL, but is not garaunteed to exist */
char * nautilus_get_desktop_directory_uri_no_create (void);
/* A version of gnome's gnome_pixmap_file that works for the nautilus prefix.
* Otherwise similar to gnome_pixmap_file in that it checks to see if the file
* exists and returns NULL if it doesn't.
......
......@@ -1710,6 +1710,19 @@ file_has_note (NautilusFile *file)
return res;
}
static gboolean
file_is_desktop (NautilusFile *file)
{
char *desktop_uri;
gboolean res;
desktop_uri = nautilus_get_desktop_directory_uri_no_create ();
res = nautilus_file_matches_uri (file, desktop_uri);
g_free (desktop_uri);
return res;
}
static int
get_automatic_emblems_as_integer (NautilusFile *file)
{
......@@ -1725,6 +1738,8 @@ get_automatic_emblems_as_integer (NautilusFile *file)
integer <<= 1;
integer |= file_has_note (file);
integer <<= 1;
integer |= file_is_desktop (file);
integer <<= 1;
#if TRASH_IS_FAST_ENOUGH
integer |= nautilus_file_is_in_trash (file);
#endif
......@@ -1744,6 +1759,10 @@ prepend_automatic_emblem_names (NautilusFile *file,
(names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_TRASH));
}
#endif
if (file_is_desktop (file)) {
names = g_list_prepend
(names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_DESKTOP));
}
if (file_has_note (file)) {
names = g_list_prepend
(names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_NOTE));
......
......@@ -73,6 +73,7 @@ typedef enum {
#define NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE "nowrite"
#define NAUTILUS_FILE_EMBLEM_NAME_TRASH "trash"
#define NAUTILUS_FILE_EMBLEM_NAME_NOTE "note"
#define NAUTILUS_FILE_EMBLEM_NAME_DESKTOP "desktop"
typedef void (*NautilusFileCallback) (NautilusFile *file,
gpointer callback_data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment