Ignore some Makefile and Makefile.in files.

* components/services/install/idl/.cvsignore:
	* components/services/time/idl/.cvsignore:
	Ignore some Makefile and Makefile.in files.

	* data/linksets/Makefile.am:
	* data/linksets/desktop.xml:
	Added a link set for the trash on the desktop.

	* icons/Makefile.am:
	Added a trash icon (actually a copy of the Nautilus icon right
	now :-).

	* libnautilus-extensions/nautilus-link-set.h:
	* libnautilus-extensions/nautilus-link-set.c: (create_new_link),
	(nautilus_link_set_install), (nautilus_link_set_remove):
	Fixed some URI-related issues and added a special case for the ~
	character so we can have link sets that are for the home directory.

	* libnautilus-extensions/nautilus-string.c:
	(nautilus_str_capitalize): Got rid of the unneeded call to strlen.
	strlen == 0 is the slowest way I know to check for an empty string.
	Also check islower before calling toupper for paranoia like the
	calls in glib do (internally).

	* src/nautilus-desktop-window.c: (nautilus_desktop_window_new):
	Install the desktop link set when we are created. For now this
	installs the trash (in a fairly lame way).

	* src/nautilus-property-browser.c: (remove_color),
	(add_color_to_file), (make_properties_from_xml_node),
	(nautilus_property_browser_update_contents):
	Changed code to not reference "childs" directly so it's easy to
	switch to a new version of gnome-xml.

	* test/.cvsignore: Ignore test-nautilus-mime-actions-set.
This commit is contained in:
Darin Adler 2000-06-02 17:25:00 +00:00
parent 8e29ec7faf
commit a51a8ee58c
16 changed files with 209 additions and 115 deletions

View file

@ -1,3 +1,41 @@
2000-06-02 Darin Adler <darin@eazel.com>
* components/services/install/idl/.cvsignore:
* components/services/time/idl/.cvsignore:
Ignore some Makefile and Makefile.in files.
* data/linksets/Makefile.am:
* data/linksets/desktop.xml:
Added a link set for the trash on the desktop.
* icons/Makefile.am:
Added a trash icon (actually a copy of the Nautilus icon right
now :-).
* libnautilus-extensions/nautilus-link-set.h:
* libnautilus-extensions/nautilus-link-set.c: (create_new_link),
(nautilus_link_set_install), (nautilus_link_set_remove):
Fixed some URI-related issues and added a special case for the ~
character so we can have link sets that are for the home directory.
* libnautilus-extensions/nautilus-string.c:
(nautilus_str_capitalize): Got rid of the unneeded call to strlen.
strlen == 0 is the slowest way I know to check for an empty string.
Also check islower before calling toupper for paranoia like the
calls in glib do (internally).
* src/nautilus-desktop-window.c: (nautilus_desktop_window_new):
Install the desktop link set when we are created. For now this
installs the trash (in a fairly lame way).
* src/nautilus-property-browser.c: (remove_color),
(add_color_to_file), (make_properties_from_xml_node),
(nautilus_property_browser_update_contents):
Changed code to not reference "childs" directly so it's easy to
switch to a new version of gnome-xml.
* test/.cvsignore: Ignore test-nautilus-mime-actions-set.
2000-06-02 Ramiro Estrugo <ramiro@eazel.com>
Task 518. Support for changing preferecens individually
@ -122,7 +160,6 @@
It would be a lot nicer it the contents updated on the fly instead
of rebuilding the whole thing. I can do that later.
2000-06-02 Pavel Cisler <pavel@eazel.com>

View file

@ -0,0 +1,2 @@
Makefile
Makefile.in

View file

@ -0,0 +1,2 @@
Makefile
Makefile.in

View file

@ -4,6 +4,7 @@ linkdir = $(datadir)/nautilus/linksets
link_DATA = \
apps.xml \
desktop.xml \
$(NULL)
EXTRA_DIST = $(link_DATA)

View file

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<linkset name="Desktop">
<link name="Trash" image="trash.png" uri="~/Trash"/>
</linkset>

View file

@ -141,6 +141,7 @@ icon_DATA =\
rightarrow.png \
tableft.png \
tabright.png \
trash.png \
uparrow.png \
zoom.png \
$(NULL)

BIN
icons/trash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -23,32 +23,34 @@
*/
#include <config.h>
#include "nautilus-link-set.h"
#include <stdlib.h>
#include <parser.h>
#include <xmlmemory.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include "nautilus-file.h"
#include "nautilus-link.h"
#include "nautilus-metadata.h"
#include "nautilus-string.h"
#include "nautilus-xml-extensions.h"
#include "nautilus-global-preferences.h"
#include "nautilus-widgets/nautilus-preferences.h"
#include "nautilus-link-set.h"
#include <nautilus-widgets/nautilus-preferences.h>
/* routine to create a new .link file in the specified directory */
static void
create_new_link(const char *directory_path, const char *name, const char *image, const char *uri)
static gboolean
create_new_link (const char *directory_path, const char *name, const char *image, const char *uri)
{
xmlDocPtr output_document;
xmlNodePtr root_node;
char *file_name;
int result;
/* create a new xml document */
output_document = xmlNewDoc ("1.0");
output_document = xmlNewDoc ("1.0");
/* add the root node to the output document */
root_node = xmlNewDocNode (output_document, NULL, "NAUTILUS_OBJECT", NULL);
@ -57,12 +59,14 @@ create_new_link(const char *directory_path, const char *name, const char *image,
xmlSetProp (root_node, "CUSTOM_ICON", image);
xmlSetProp (root_node, "LINK", uri);
/* all done , so save the xml document as a link file */
file_name = g_strdup_printf("%s/%s.link", directory_path, name);
result = xmlSaveFile(file_name, output_document);
g_free(file_name);
/* all done, so save the xml document as a link file */
file_name = g_strdup_printf ("%s/%s.link", directory_path, name);
result = xmlSaveFile (file_name, output_document);
g_free (file_name);
xmlFreeDoc(output_document);
xmlFreeDoc (output_document);
return result > 0;
}
/* install a link set into the specified directory */
@ -70,54 +74,62 @@ create_new_link(const char *directory_path, const char *name, const char *image,
gboolean
nautilus_link_set_install (const char *directory_path, const char *link_set_name)
{
NautilusFile *file;
xmlDocPtr document;
xmlNodePtr cur_node;
xmlNodePtr node;
char *temp_str, *link_set_path;
char *link_name, *image_name, *uri_name;
char *link_name, *image_name, *uri, *full_uri, *home_in_uri_format;
file = nautilus_file_get(directory_path);
if (file == NULL)
return FALSE;
/* make sure the target is a writable directory */
if (!nautilus_file_is_directory(file) || !nautilus_file_can_write(file)) {
nautilus_file_unref(file);
return FALSE;
}
/* compose the path of the link set file */
temp_str = g_strdup_printf ("nautilus/linksets/%s.xml", link_set_name);
link_set_path = gnome_datadir_file (temp_str);
g_free (temp_str);
/* load and parse the linkset xml file */
document = xmlParseFile (link_set_path);
g_free(temp_str);
g_free(link_set_path);
if (document == NULL)
g_free (link_set_path);
if (document == NULL) {
return FALSE;
}
/* loop through the entries, generating .link files */
for (cur_node = document->root->childs; cur_node != NULL; cur_node = cur_node->next) {
if (strcmp(cur_node->name, "link") == 0) {
link_name = xmlGetProp (cur_node, "name");
image_name = xmlGetProp (cur_node, "image");
uri_name = xmlGetProp (cur_node, "uri");
create_new_link(directory_path, link_name, image_name, uri_name);
for (node = nautilus_xml_get_children (xmlDocGetRootElement (document));
node != NULL; node = node->next) {
if (strcmp (node->name, "link") == 0) {
link_name = xmlGetProp (node, "name");
image_name = xmlGetProp (node, "image");
uri = xmlGetProp (node, "uri");
/* Expand special URIs */
full_uri = NULL;
if (uri[0] == '~') {
home_in_uri_format = gnome_vfs_escape_string
(g_get_home_dir (), GNOME_VFS_URI_UNSAFE_PATH);
full_uri = g_strconcat ("file://", home_in_uri_format, uri + 1, NULL);
g_free (home_in_uri_format);
uri = full_uri;
}
if (!create_new_link (directory_path, link_name, image_name, uri)) {
g_free (full_uri);
xmlFreeDoc (document);
return FALSE;
}
g_free (full_uri);
}
}
/* all done so return TRUE */
xmlFreeDoc(document);
return TRUE;
xmlFreeDoc (document);
/* all done so return TRUE */
return TRUE;
}
/* remove a link set from the specified directory */
/* FIXME: Not implemented. */
#if 0
void
nautilus_link_set_remove (const char *directory_uri, const char *link_set_name)
nautilus_link_set_remove (const char *directory_uri, const char *link_set_name)
{
}
#endif

View file

@ -27,8 +27,9 @@
#include <glib.h>
gboolean nautilus_link_set_install (const char *file_uri, const char *link_set_name);
void nautilus_link_set_remove (const char *file_uri, const char *link_set_name);
gboolean nautilus_link_set_install (const char *directory_path,
const char *link_set_name);
void nautilus_link_set_remove (const char *directory_path,
const char *link_set_name);
#endif /* NAUTILUS_LINK_H */
#endif /* NAUTILUS_LINK_SET_H */

View file

@ -353,8 +353,8 @@ nautilus_str_capitalize (const char *string)
capitalized = g_strdup (string);
if (strlen (string) > 0) {
capitalized[0] = toupper (string[0]);
if (islower (capitalized[0])) {
capitalized[0] = toupper (capitalized[0]);
}
return capitalized;

View file

@ -23,32 +23,34 @@
*/
#include <config.h>
#include "nautilus-link-set.h"
#include <stdlib.h>
#include <parser.h>
#include <xmlmemory.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include "nautilus-file.h"
#include "nautilus-link.h"
#include "nautilus-metadata.h"
#include "nautilus-string.h"
#include "nautilus-xml-extensions.h"
#include "nautilus-global-preferences.h"
#include "nautilus-widgets/nautilus-preferences.h"
#include "nautilus-link-set.h"
#include <nautilus-widgets/nautilus-preferences.h>
/* routine to create a new .link file in the specified directory */
static void
create_new_link(const char *directory_path, const char *name, const char *image, const char *uri)
static gboolean
create_new_link (const char *directory_path, const char *name, const char *image, const char *uri)
{
xmlDocPtr output_document;
xmlNodePtr root_node;
char *file_name;
int result;
/* create a new xml document */
output_document = xmlNewDoc ("1.0");
output_document = xmlNewDoc ("1.0");
/* add the root node to the output document */
root_node = xmlNewDocNode (output_document, NULL, "NAUTILUS_OBJECT", NULL);
@ -57,12 +59,14 @@ create_new_link(const char *directory_path, const char *name, const char *image,
xmlSetProp (root_node, "CUSTOM_ICON", image);
xmlSetProp (root_node, "LINK", uri);
/* all done , so save the xml document as a link file */
file_name = g_strdup_printf("%s/%s.link", directory_path, name);
result = xmlSaveFile(file_name, output_document);
g_free(file_name);
/* all done, so save the xml document as a link file */
file_name = g_strdup_printf ("%s/%s.link", directory_path, name);
result = xmlSaveFile (file_name, output_document);
g_free (file_name);
xmlFreeDoc(output_document);
xmlFreeDoc (output_document);
return result > 0;
}
/* install a link set into the specified directory */
@ -70,54 +74,62 @@ create_new_link(const char *directory_path, const char *name, const char *image,
gboolean
nautilus_link_set_install (const char *directory_path, const char *link_set_name)
{
NautilusFile *file;
xmlDocPtr document;
xmlNodePtr cur_node;
xmlNodePtr node;
char *temp_str, *link_set_path;
char *link_name, *image_name, *uri_name;
char *link_name, *image_name, *uri, *full_uri, *home_in_uri_format;
file = nautilus_file_get(directory_path);
if (file == NULL)
return FALSE;
/* make sure the target is a writable directory */
if (!nautilus_file_is_directory(file) || !nautilus_file_can_write(file)) {
nautilus_file_unref(file);
return FALSE;
}
/* compose the path of the link set file */
temp_str = g_strdup_printf ("nautilus/linksets/%s.xml", link_set_name);
link_set_path = gnome_datadir_file (temp_str);
g_free (temp_str);
/* load and parse the linkset xml file */
document = xmlParseFile (link_set_path);
g_free(temp_str);
g_free(link_set_path);
if (document == NULL)
g_free (link_set_path);
if (document == NULL) {
return FALSE;
}
/* loop through the entries, generating .link files */
for (cur_node = document->root->childs; cur_node != NULL; cur_node = cur_node->next) {
if (strcmp(cur_node->name, "link") == 0) {
link_name = xmlGetProp (cur_node, "name");
image_name = xmlGetProp (cur_node, "image");
uri_name = xmlGetProp (cur_node, "uri");
create_new_link(directory_path, link_name, image_name, uri_name);
for (node = nautilus_xml_get_children (xmlDocGetRootElement (document));
node != NULL; node = node->next) {
if (strcmp (node->name, "link") == 0) {
link_name = xmlGetProp (node, "name");
image_name = xmlGetProp (node, "image");
uri = xmlGetProp (node, "uri");
/* Expand special URIs */
full_uri = NULL;
if (uri[0] == '~') {
home_in_uri_format = gnome_vfs_escape_string
(g_get_home_dir (), GNOME_VFS_URI_UNSAFE_PATH);
full_uri = g_strconcat ("file://", home_in_uri_format, uri + 1, NULL);
g_free (home_in_uri_format);
uri = full_uri;
}
if (!create_new_link (directory_path, link_name, image_name, uri)) {
g_free (full_uri);
xmlFreeDoc (document);
return FALSE;
}
g_free (full_uri);
}
}
/* all done so return TRUE */
xmlFreeDoc(document);
return TRUE;
xmlFreeDoc (document);
/* all done so return TRUE */
return TRUE;
}
/* remove a link set from the specified directory */
/* FIXME: Not implemented. */
#if 0
void
nautilus_link_set_remove (const char *directory_uri, const char *link_set_name)
nautilus_link_set_remove (const char *directory_uri, const char *link_set_name)
{
}
#endif

View file

@ -27,8 +27,9 @@
#include <glib.h>
gboolean nautilus_link_set_install (const char *file_uri, const char *link_set_name);
void nautilus_link_set_remove (const char *file_uri, const char *link_set_name);
gboolean nautilus_link_set_install (const char *directory_path,
const char *link_set_name);
void nautilus_link_set_remove (const char *directory_path,
const char *link_set_name);
#endif /* NAUTILUS_LINK_H */
#endif /* NAUTILUS_LINK_SET_H */

View file

@ -353,8 +353,8 @@ nautilus_str_capitalize (const char *string)
capitalized = g_strdup (string);
if (strlen (string) > 0) {
capitalized[0] = toupper (string[0]);
if (islower (capitalized[0])) {
capitalized[0] = toupper (capitalized[0]);
}
return capitalized;

View file

@ -28,7 +28,9 @@
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-gtk-extensions.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-link-set.h>
#include <libgnomeui/gnome-winhints.h>
#include <libgnomevfs/gnome-vfs-utils.h>
struct NautilusDesktopWindowDetails {
GList *unref_list;
@ -83,7 +85,9 @@ NautilusDesktopWindow *
nautilus_desktop_window_new (NautilusApp *application)
{
NautilusDesktopWindow *window;
char *desktop_directory;
const char *desktop_directory_path;
char *desktop_directory_path_in_uri_format;
char *desktop_directory_uri;
window = NAUTILUS_DESKTOP_WINDOW
(gtk_object_new (nautilus_desktop_window_get_type(),
@ -91,12 +95,29 @@ nautilus_desktop_window_new (NautilusApp *application)
"app_id", "nautilus",
NULL));
desktop_directory_path = nautilus_get_desktop_directory ();
/* Create the trash.
* We can do this at some other time if we want, but this
* might be a good time.
*/
nautilus_link_set_install (desktop_directory_path, "desktop");
/* FIXME: This little ditty is just the way you convert a
* local path to a file: URI. Should be a utility somewhere
* to do the two steps at once.
*/
desktop_directory_path_in_uri_format = gnome_vfs_escape_string
(desktop_directory_path, GNOME_VFS_URI_UNSAFE_PATH);
desktop_directory_uri = g_strconcat
("file://", desktop_directory_path_in_uri_format, NULL);
g_free (desktop_directory_path_in_uri_format);
/* Point window at the desktop folder.
* Note that nautilus_desktop_window_initialize is too early to do this.
*/
desktop_directory = g_strconcat ("file://", nautilus_get_desktop_directory (), NULL);
nautilus_window_goto_uri (NAUTILUS_WINDOW (window), desktop_directory);
g_free (desktop_directory);
nautilus_window_goto_uri (NAUTILUS_WINDOW (window), desktop_directory_uri);
g_free (desktop_directory_uri);
gtk_widget_show (GTK_WIDGET (window));

View file

@ -49,6 +49,7 @@
#include <libnautilus-extensions/nautilus-gnome-extensions.h>
#include <libnautilus-extensions/nautilus-metadata.h>
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-xml-extensions.h>
struct NautilusPropertyBrowserDetails {
GtkVBox *container;
@ -513,16 +514,18 @@ remove_color(NautilusPropertyBrowser *property_browser, const char* color_value)
xmlDocPtr document = xmlParseFile (xml_path);
g_free(xml_path);
if (document == NULL)
if (document == NULL) {
return;
}
/* find the colors category */
for (cur_node = document->root->childs; cur_node != NULL; cur_node = cur_node->next) {
for (cur_node = nautilus_xml_get_children (xmlDocGetRootElement (document));
cur_node != NULL; cur_node = cur_node->next) {
if (strcmp(cur_node->name, "category") == 0) {
char* category_name = xmlGetProp (cur_node, "name");
if (strcmp(category_name, "colors") == 0) {
/* loop through the colors to find one that matches */
xmlNodePtr color_node = cur_node->childs;
xmlNodePtr color_node = nautilus_xml_get_children (cur_node);
while (color_node != NULL) {
char* color_content = xmlNodeGetContent(color_node);
if (color_content && !strcmp(color_content, color_value)) {
@ -852,8 +855,8 @@ add_color_to_file(NautilusPropertyBrowser *property_browser, const char *color_s
}
/* find the colors category */
cur_node = document->root->childs;
for (cur_node = document->root->childs; cur_node != NULL; cur_node = cur_node->next) {
for (cur_node = nautilus_xml_get_children (xmlDocGetRootElement (document));
cur_node != NULL; cur_node = cur_node->next) {
if (strcmp(cur_node->name, "category") == 0) {
char* category_name = xmlGetProp (cur_node, "name");
if (strcmp(category_name, "colors") == 0) {
@ -1267,15 +1270,16 @@ make_properties_from_directory(NautilusPropertyBrowser *property_browser, const
/* for now, we just handle color nodes */
static void
make_properties_from_xml_node(NautilusPropertyBrowser *property_browser, xmlNodePtr node)
make_properties_from_xml_node (NautilusPropertyBrowser *property_browser, xmlNodePtr node)
{
xmlNode *current_node = node->childs;
xmlNode *current_node;
int index = 0;
gboolean local_only = property_browser->details->remove_mode;
property_browser->details->has_local = FALSE;
while (current_node != NULL) {
for (current_node = nautilus_xml_get_children (node);
current_node != NULL; current_node = current_node->next) {
NautilusBackground *background;
GtkWidget *frame;
char* color_str = xmlNodeGetContent(current_node);
@ -1312,8 +1316,6 @@ make_properties_from_xml_node(NautilusPropertyBrowser *property_browser, xmlNode
add_to_content_table(property_browser, frame, index++, 12);
}
current_node = current_node->next;
}
}
@ -1424,8 +1426,8 @@ nautilus_property_browser_update_contents (NautilusPropertyBrowser *property_bro
gtk_widget_show (GTK_WIDGET (property_browser->details->content_table));
/* iterate through the xml file to generate the widgets */
cur_node = document->root->childs;
while (cur_node != NULL) {
for (cur_node = nautilus_xml_get_children (xmlDocGetRootElement (document));
cur_node != NULL; cur_node = cur_node->next) {
if (strcmp(cur_node->name, "category") == 0) {
char* category_name = xmlGetProp (cur_node, "name");
char* category_image = xmlGetProp (cur_node, "image");
@ -1442,13 +1444,10 @@ nautilus_property_browser_update_contents (NautilusPropertyBrowser *property_bro
make_category_link(property_browser, category_name, category_image, index++);
}
}
cur_node = cur_node->next;
}
/* release the xml document and we're done */
if (document) {
xmlFreeDoc(document);
}
xmlFreeDoc (document);
/* update the title and button */

View file

@ -3,3 +3,4 @@
Makefile
Makefile.in
test-nautilus-mime-actions
test-nautilus-mime-actions-set