Ignoring OnlyShowIn desktop files, again
- From: Federico Mena Quintero <federico ximian com>
- To: nautilus-list gnome org
- Subject: Ignoring OnlyShowIn desktop files, again
- Date: Wed, 26 Mar 2008 23:13:39 -0600
Hi,
A long time ago I wrote a patch for
http://bugzilla.gnome.org/show_bug.cgi?id=338933 - don't show .desktop
files which have something like "OnlyShowIn=KDE". Alex didn't like the
patch because it used synchronous I/O, and it hid those files
everywhere, not just in the desktop.
I've written a new version of the patch, which is (wheee!) totally
untested :) But does this seem like a better approach? I'm reusing the
NautilusFile / NautilusLink machinery to read .desktop files
asynchronously. I'll have a chance of testing this tomorrow.
Federico
2008-03-26 Federico Mena Quintero <federico novell com>
Do not show .desktop files in ~/Desktop which are OnlyShowIn=KDE
or similar.
http://bugzilla.gnome.org/show_bug.cgi?id=338933
https://bugzilla.novell.com/show_bug.cgi?id=366100
* libnautilus-private/nautilus-link.c
(nautilus_link_get_link_info_given_file_contents): Add a return
"is_foreign" argument, which says if OnlyShowIn/NotShowIn within
the .desktop file say that it shouldn't be shown in GNOME.
* libnautilus-private/nautilus-directory-async.c
(link_info_got_data): Use the is_foreign information.
(link_info_done): Store file->details->is_foreign_link.
* libnautilus-private/nautilus-file-private.h (struct
NautilusFileDetails): Add an is_foreign_link field.
* libnautilus-private/nautilus-file.c (nautilus_file_clear_info):
Initialize is_foreign_link.
(nautilus_file_is_foreign_link): New public function.
(nautilus_file_should_show): Don't show foreign links in the
desktop directory.
diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c
index c1d0a0a..36eb02f 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -198,7 +198,8 @@ static void link_info_done (NautilusDirectory
const char *uri,
const char *name,
const char *icon,
- gboolean is_launcher);
+ gboolean is_launcher,
+ gboolean is_foreign);
static void move_file_to_low_priority_queue (NautilusDirectory *directory,
NautilusFile *file);
static void move_file_to_extension_queue (NautilusDirectory *directory,
@@ -1716,7 +1717,7 @@ lacks_link_info (NautilusFile *file)
if (nautilus_file_is_nautilus_link (file)) {
return TRUE;
} else {
- link_info_done (file->details->directory, file, NULL, NULL, NULL, FALSE);
+ link_info_done (file->details->directory, file, NULL, NULL, NULL, FALSE, FALSE);
return FALSE;
}
} else {
@@ -3515,7 +3516,8 @@ link_info_done (NautilusDirectory *directory,
const char *uri,
const char *name,
const char *icon,
- gboolean is_launcher)
+ gboolean is_launcher,
+ gboolean is_foreign)
{
file->details->link_info_is_up_to_date = TRUE;
@@ -3533,6 +3535,7 @@ link_info_done (NautilusDirectory *directory,
}
file->details->custom_icon = g_strdup (icon);
file->details->is_launcher = is_launcher;
+ file->details->is_foreign_link = is_foreign;
nautilus_directory_async_state_changed (directory);
}
@@ -3579,6 +3582,7 @@ link_info_got_data (NautilusDirectory *directory,
{
char *uri, *name, *icon;
gboolean is_launcher;
+ gboolean is_foreign;
nautilus_directory_ref (directory);
@@ -3586,17 +3590,18 @@ link_info_got_data (NautilusDirectory *directory,
name = NULL;
icon = NULL;
is_launcher = FALSE;
+ is_foreign = FALSE;
/* Handle the case where we read the Nautilus link. */
if (result) {
nautilus_link_get_link_info_given_file_contents (file_contents, bytes_read,
- &uri, &name, &icon, &is_launcher);
+ &uri, &name, &icon, &is_launcher, &is_foreign);
} else {
/* FIXME bugzilla.gnome.org 42433: We should report this error to the user. */
}
nautilus_file_ref (file);
- link_info_done (directory, file, uri, name, icon, is_launcher);
+ link_info_done (directory, file, uri, name, icon, is_launcher, is_foreign);
nautilus_file_changed (file);
nautilus_file_unref (file);
@@ -3684,7 +3689,7 @@ link_info_start (NautilusDirectory *directory,
/* If it's not a link we are done. If it is, we need to read it. */
if (!nautilus_style_link) {
- link_info_done (directory, file, NULL, NULL, NULL, FALSE);
+ link_info_done (directory, file, NULL, NULL, NULL, FALSE, FALSE);
} else if (should_read_link_info_sync (file)) {
result = g_file_load_contents (location, NULL, &file_contents, &file_size, NULL, NULL);
link_info_got_data (directory, file, result, file_size, file_contents);
diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h
index 8420a7e..2552cf9 100644
--- a/libnautilus-private/nautilus-file-private.h
+++ b/libnautilus-private/nautilus-file-private.h
@@ -190,6 +190,7 @@ struct NautilusFileDetails
eel_boolean_bit has_open_window : 1;
eel_boolean_bit is_launcher : 1;
+ eel_boolean_bit is_foreign_link : 1;
eel_boolean_bit is_symlink : 1;
eel_boolean_bit is_mountpoint : 1;
eel_boolean_bit is_hidden : 1;
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 88139eb..23f01df 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -323,6 +323,7 @@ nautilus_file_clear_info (NautilusFile *file)
file->details->thumbnailing_failed = FALSE;
file->details->is_launcher = FALSE;
+ file->details->is_foreign_link = FALSE;
file->details->is_symlink = FALSE;
file->details->is_hidden = FALSE;
file->details->is_backup = FALSE;
@@ -2705,7 +2706,8 @@ nautilus_file_should_show (NautilusFile *file,
gboolean show_hidden,
gboolean show_backup)
{
- return (show_hidden || (!nautilus_file_is_hidden_file (file) && !is_file_hidden (file))) &&
+ return (show_hidden || (!nautilus_file_is_hidden_file (file) && !is_file_hidden (file) &&
+ !(nautilus_file_is_in_desktop (file) && nautilus_file_is_foreign_link (file)))) &&
(show_backup || !nautilus_file_is_backup_file (file));
}
@@ -3038,6 +3040,12 @@ nautilus_file_is_launcher (NautilusFile *file)
}
gboolean
+nautilus_file_is_foreign_link (NautilusFile *file)
+{
+ return file->details->is_foreign_link;
+}
+
+gboolean
nautilus_file_has_activation_uri (NautilusFile *file)
{
return file->details->activation_location != NULL;
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 99e0aeb..9db13f9 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -378,6 +378,7 @@ GList *nautilus_file_list_filter_hidden_and_backup (GList
* Getting this can require reading the contents of the file.
*/
gboolean nautilus_file_is_launcher (NautilusFile *file);
+gboolean nautilus_file_is_foreign_link (NautilusFile *file);
gboolean nautilus_file_has_activation_uri (NautilusFile *file);
char * nautilus_file_get_activation_uri (NautilusFile *file);
GFile * nautilus_file_get_activation_location (NautilusFile *file);
diff --git a/libnautilus-private/nautilus-link.c b/libnautilus-private/nautilus-link.c
index abe244a..a6625d7 100644
--- a/libnautilus-private/nautilus-link.c
+++ b/libnautilus-private/nautilus-link.c
@@ -406,16 +406,36 @@ nautilus_link_local_get_link_uri (const char *uri)
return retval;
}
+static gboolean
+string_array_contains (char **array,
+ const char *str)
+{
+ char **p;
+
+ if (!array)
+ return FALSE;
+
+ for (p = array; *p; p++)
+ if (g_ascii_strcasecmp (*p, str) == 0) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
void
nautilus_link_get_link_info_given_file_contents (const char *file_contents,
int link_file_size,
char **uri,
char **name,
char **icon,
- gboolean *is_launcher)
+ gboolean *is_launcher,
+ gboolean *is_foreign)
{
GnomeDesktopItem *desktop_file;
const char *type;
+ char **only_show_in;
+ char **not_show_in;
if (!is_link_data (file_contents, link_file_size)) {
return;
@@ -437,7 +457,20 @@ nautilus_link_get_link_info_given_file_contents (const char *file_contents,
gnome_desktop_item_get_string (desktop_file, "Exec") != NULL) {
*is_launcher = TRUE;
}
-
+
+ *is_foreign = FALSE;
+ only_show_in = gnome_desktop_item_get_strings (desktop_file, GNOME_DESKTOP_ITEM_ONLY_SHOW_IN);
+ if (only_show_in && !string_array_contains (only_show_in, "GNOME")) {
+ *is_foreign = TRUE;
+ }
+ g_strfreev (only_show_in);
+
+ not_show_in = gnome_desktop_item_get_strings (desktop_file, "NotShowIn"); /* bleh, there isn't GNOME_DESKTOP_ITEM_NO_SHOW_IN */
+ if (not_show_in && string_array_contains (not_show_in, "GNOME")) {
+ *is_foreign = TRUE;
+ }
+ g_strfreev (not_show_in);
+
gnome_desktop_item_unref (desktop_file);
}
diff --git a/libnautilus-private/nautilus-link.h b/libnautilus-private/nautilus-link.h
index 4a5eb94..aba3103 100644
--- a/libnautilus-private/nautilus-link.h
+++ b/libnautilus-private/nautilus-link.h
@@ -46,7 +46,8 @@ void nautilus_link_get_link_info_given_file_contents (const char
char **uri,
char **name,
char **icon,
- gboolean *is_launcher);
+ gboolean *is_launcher,
+ gboolean *is_foreign);
void nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *entry,
const char *dest_uri,
const GdkPoint *position,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]