mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-09-19 07:41:26 +00:00
e82bab8c49
Fixed bug 2147 (NautilusFile for trash needs non-empty values for more properties), bug 5652 (MIME type field appears but shouldn't in properties window for Trash), and bug 4620 (trash sidebar should show number of items). * libnautilus-extensions/nautilus-file.h: * libnautilus-extensions/nautilus-file-private.h: * libnautilus-extensions/nautilus-file.c: (nautilus_file_new_from_relative_uri): Create trash file subclass when appropriate. (nautilus_file_info_missing): Rename so it can be used in other source files. (nautilus_file_get_date): New method that returns numeric dates. (nautilus_file_get_date_as_string): Change to call nautilus_file_get_date to get the numeric date. (nautilus_file_get_file_type): Turn into a method. * libnautilus-extensions/nautilus-merged-directory.h: * libnautilus-extensions/nautilus-merged-directory.c: (merged_call_when_ready): Rolled in the old merged_callback_connect_directory function. (merged_contains_file): Moved down to a more appropriate part of the source file. (nautilus_merged_directory_get_real_directories): New public function for use by trash. * libnautilus-extensions/nautilus-trash-file.c: (trash_callback_hash), (trash_callback_equal), (trash_callback_destroy), (trash_callback_check_done), (trash_callback_remove_file), (ready_callback), (real_file_changed_callback), (monitor_add_file), (add_real_file), (trash_callback_remove_file_cover), (monitor_remove_file), (remove_real_file), (add_real_file_given_directory), (add_directory_callback), (remove_directory_callback), (trash_file_call_when_ready), (trash_file_cancel_call_when_ready), (trash_file_check_if_ready), (trash_file_monitor_add), (trash_file_monitor_remove), (trash_file_get_file_type), (trash_file_get_item_count), (trash_file_get_deep_counts), (trash_file_get_date), (remove_all_real_files), (nautilus_trash_file_initialize), (trash_destroy), (nautilus_trash_file_initialize_class): New code. First implementation of getting some attributes for the merged trash. Gets list of directories from the NautilusTrashDirectory object. The code in here is similar to the NautilusMergedDirectory class and at some point perhaps we can make the two share more. * libnautilus-extensions/nautilus-vfs-file.c: (vfs_file_get_file_type), (vfs_file_get_date), (nautilus_vfs_file_initialize_class): Implement the two new methods for the standard vfs case. Fixed various things that affect the properties window for the trash that showed up while I was testing the above work: * libnautilus-extensions/nautilus-icon-factory.c: (nautilus_icon_factory_get_icon_name_for_regular_file), (nautilus_icon_factory_get_icon_name_for_file): Move trash special case out so it doesn't matter what type the trash seems to be. The old code relied on trash not being a directory. * src/file-manager/fm-properties-window.c: (create_properties_window), (create_properties_window_callback), (cancel_create_properties_window_callback), (directory_view_destroyed_callback), (remove_pending_file): Rework code to fix problems where the timed wait or the signal handler wasn't properly cleaned up. Fixed remaining bit of bug 5631 (Tear-offs of right-click menus don't work.): * src/file-manager/nautilus-desktop-icon-view-ui.xml: Mark Disks right-click submenu so it won't get a tear-off item. Fixed bug 5650 (nautilus --quit fails to return to prompt sometimes): * src/nautilus-application.c: (nautilus_application_startup): Add special case so "nautilus --quit" doesn't hang waiting for a response from the (now quit) "server" instance of Nautilus. * src/nautilus-shell-interface.idl: Had to make the quit call no longer be "oneway" to get it to work right, otherwise the quit message could be lost when the sending application exited too fast. Fix bug 5675 (Nitpicks in new "could not be moved to new special location" dialog): * libnautilus-extensions/nautilus-file-operations.c: (handle_transfer_overwrite): Updated message wording as Eli (and Vera) suggest. Other changes: * libnautilus-extensions/nautilus-view-identifier.c: (get_lang_list): Fix comment and a small storage leak in the case where lang_with_locale is non-NULL but empty. * po/POTFILES.ignore: Obsolete file, no longer used. * src/file-manager/fm-desktop-icon-view.c: (update_home_link_and_delete_copies): Update comment to help translators understand better. * libnautilus-extensions/nautilus-directory-async.c: (directory_load_callback): Added a new assertion that could help in future gnome-vfs debugging. * libnautilus/nautilus-view-component.idl: Removed long-ago-fixed FIXME comment. * src/nautilus-window-manage-views.c: Tweak spacing.
211 lines
5.5 KiB
C
211 lines
5.5 KiB
C
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
|
|
|
|
nautilus-view-identifier.c: Unique ID/Human-readable name pairs for views
|
|
|
|
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.
|
|
|
|
Author: Maciej Stachowiak <mjs@eazel.com>
|
|
*/
|
|
|
|
#include <config.h>
|
|
#include "nautilus-view-identifier.h"
|
|
|
|
#include "nautilus-glib-extensions.h"
|
|
#include "nautilus-string.h"
|
|
#include <glib.h>
|
|
#include <stdlib.h>
|
|
|
|
NautilusViewIdentifier *
|
|
nautilus_view_identifier_new (const char *iid, const char *name)
|
|
{
|
|
NautilusViewIdentifier *new_identifier;
|
|
|
|
g_return_val_if_fail (iid != NULL, NULL);
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
new_identifier = g_new0 (NautilusViewIdentifier, 1);
|
|
new_identifier->iid = g_strdup (iid);
|
|
new_identifier->name = g_strdup (name);
|
|
|
|
return new_identifier;
|
|
}
|
|
|
|
NautilusViewIdentifier *
|
|
nautilus_view_identifier_copy (NautilusViewIdentifier *identifier)
|
|
{
|
|
if (identifier == NULL) {
|
|
return NULL;
|
|
}
|
|
|
|
return nautilus_view_identifier_new (identifier->iid, identifier->name);
|
|
}
|
|
|
|
/* Returns a list of languages, containing
|
|
the LANG or LANGUAGE environment setting (with and without region code).
|
|
The elements in the returned list must be freed */
|
|
static GSList *
|
|
get_lang_list (void)
|
|
{
|
|
GSList *retval;
|
|
char *lang, *lang_with_locale, *tmp, *org_pointer;
|
|
char *equal_char;
|
|
|
|
retval = NULL;
|
|
|
|
tmp = g_getenv ("LANGUAGE");
|
|
|
|
if (tmp == NULL) {
|
|
tmp = g_getenv ("LANG");
|
|
}
|
|
|
|
lang = g_strdup (tmp);
|
|
org_pointer = lang;
|
|
|
|
if (lang != NULL) {
|
|
/* envs can be in NAME=VALUE form */
|
|
equal_char = strchr (lang, '=');
|
|
if (equal_char != NULL) {
|
|
lang = equal_char + 1;
|
|
}
|
|
|
|
/* lang may be in form LANG_LOCALE */
|
|
equal_char = strchr (lang, '_');
|
|
if (equal_char != NULL) {
|
|
lang_with_locale = g_strdup (lang);
|
|
*equal_char = 0;
|
|
} else {
|
|
lang_with_locale = NULL;
|
|
}
|
|
|
|
/* Make sure we don't give oaf an empty
|
|
lang string */
|
|
if (!nautilus_str_is_empty (lang_with_locale)) {
|
|
retval = g_slist_prepend (retval,
|
|
g_strdup (lang_with_locale));
|
|
}
|
|
g_free (lang_with_locale);
|
|
if (!nautilus_str_is_empty (lang)) {
|
|
retval = g_slist_prepend (retval, g_strdup (lang));
|
|
}
|
|
}
|
|
g_free (org_pointer);
|
|
|
|
return retval;
|
|
}
|
|
|
|
NautilusViewIdentifier *
|
|
nautilus_view_identifier_new_from_oaf_server_info (OAF_ServerInfo *server, char *name_attribute)
|
|
{
|
|
const char *view_as_name;
|
|
GSList *langs;
|
|
|
|
langs = get_lang_list ();
|
|
|
|
view_as_name = oaf_server_info_prop_lookup (server, name_attribute, langs);
|
|
if (view_as_name == NULL) {
|
|
view_as_name = oaf_server_info_prop_lookup (server, "name", langs);
|
|
}
|
|
if (view_as_name == NULL) {
|
|
view_as_name = server->iid;
|
|
}
|
|
|
|
g_slist_foreach (langs, (GFunc)g_free, NULL);
|
|
g_slist_free (langs);
|
|
|
|
/* if the name is an OAFIID, clean it up for display */
|
|
if (nautilus_str_has_prefix (view_as_name, "OAFIID:")) {
|
|
char *display_name, *colon_ptr;
|
|
NautilusViewIdentifier *new_identifier;
|
|
|
|
display_name = g_strdup (view_as_name + 7);
|
|
colon_ptr = strchr (display_name, ':');
|
|
if (colon_ptr) {
|
|
*colon_ptr = '\0';
|
|
}
|
|
|
|
new_identifier = nautilus_view_identifier_new (server->iid, display_name);
|
|
g_free(display_name);
|
|
return new_identifier;
|
|
}
|
|
|
|
return nautilus_view_identifier_new (server->iid, view_as_name);
|
|
}
|
|
|
|
NautilusViewIdentifier *
|
|
nautilus_view_identifier_new_from_content_view (OAF_ServerInfo *server)
|
|
{
|
|
return nautilus_view_identifier_new_from_oaf_server_info
|
|
(server, "nautilus:view_as_name");
|
|
}
|
|
|
|
NautilusViewIdentifier *
|
|
nautilus_view_identifier_new_from_sidebar_panel (OAF_ServerInfo *server)
|
|
{
|
|
return nautilus_view_identifier_new_from_oaf_server_info
|
|
(server, "nautilus:sidebar_panel_name");
|
|
}
|
|
|
|
void
|
|
nautilus_view_identifier_free (NautilusViewIdentifier *identifier)
|
|
{
|
|
if (identifier != NULL) {
|
|
g_free (identifier->iid);
|
|
g_free (identifier->name);
|
|
g_free (identifier);
|
|
}
|
|
}
|
|
|
|
GList *
|
|
nautilus_view_identifier_list_copy (GList *list)
|
|
{
|
|
GList *copy, *node;
|
|
|
|
copy = NULL;
|
|
for (node = list; node != NULL; node = node->next) {
|
|
copy = g_list_prepend
|
|
(copy, nautilus_view_identifier_copy (node->data));
|
|
}
|
|
return g_list_reverse (copy);
|
|
}
|
|
|
|
static void
|
|
nautilus_view_identifier_free_callback (gpointer identifier, gpointer ignore)
|
|
{
|
|
g_assert (ignore == NULL);
|
|
nautilus_view_identifier_free (identifier);
|
|
}
|
|
|
|
void
|
|
nautilus_view_identifier_list_free (GList *list)
|
|
{
|
|
nautilus_g_list_free_deep_custom
|
|
(list, nautilus_view_identifier_free_callback, NULL);
|
|
}
|
|
|
|
int
|
|
nautilus_view_identifier_compare (NautilusViewIdentifier *a, NautilusViewIdentifier *b)
|
|
{
|
|
int result;
|
|
|
|
result = strcmp (a->iid, b->iid);
|
|
if (result != 0) {
|
|
return result;
|
|
}
|
|
return strcmp (a->name, b->name);
|
|
}
|