]>
Commit | Line | Data |
---|---|---|
307ca41a | 1 | diff -urN aa/desktop-file-utils-0.7/src/menu-entries.c desktop-file-utils-0.7/src/menu-entries.c |
2 | --- aa/desktop-file-utils-0.7/src/menu-entries.c 2004-07-28 15:19:30.490876392 +0200 | |
3 | +++ desktop-file-utils-0.7/src/menu-entries.c 2004-07-28 21:28:13.552659792 +0200 | |
4 | @@ -42,6 +42,7 @@ | |
5 | char *absolute_path; | |
6 | ||
7 | unsigned int *categories; /* 0-terminated array of atoms */ | |
8 | + gboolean show; | |
9 | ||
10 | guint type : 4; | |
11 | guint refcount : 24; | |
12 | @@ -82,7 +83,8 @@ | |
13 | static Entry* | |
14 | entry_new (EntryType type, | |
15 | const char *relative_path, | |
16 | - const char *absolute_path) | |
17 | + const char *absolute_path, | |
18 | + gboolean show) | |
19 | { | |
20 | Entry *e; | |
21 | ||
22 | @@ -93,6 +95,7 @@ | |
23 | e->relative_path = g_strdup (relative_path); | |
24 | e->absolute_path = g_strdup (absolute_path); | |
25 | e->refcount = 1; | |
26 | + e->show=show; | |
27 | ||
28 | return e; | |
29 | } | |
30 | @@ -150,6 +153,11 @@ | |
31 | return entry->relative_path; | |
32 | } | |
33 | ||
34 | +gboolean entry_get_show (Entry *entry) | |
35 | +{ | |
36 | + return entry->show; | |
37 | +} | |
38 | + | |
39 | gboolean | |
40 | entry_has_category (Entry *entry, | |
41 | EntryCache *cache, | |
42 | @@ -371,7 +379,7 @@ | |
43 | return src; | |
44 | } | |
45 | ||
46 | - e = entry_new (src->type, relative_path, src->absolute_path); | |
47 | + e = entry_new (src->type, relative_path, src->absolute_path, src->show); | |
48 | ||
49 | n_categories_to_copy = 0; | |
50 | if (src->categories) | |
51 | @@ -441,7 +449,7 @@ | |
52 | if (src->type != ENTRY_DIRECTORY) | |
53 | return NULL; | |
54 | ||
55 | - e = entry_new (src->type, relative_path, src->absolute_path); | |
56 | + e = entry_new (src->type, relative_path, src->absolute_path, src->show); | |
57 | ||
58 | return e; | |
59 | } | |
60 | @@ -1874,7 +1882,7 @@ | |
61 | } | |
62 | } | |
63 | ||
64 | - e = entry_new (ENTRY_DESKTOP, basename, filename); | |
65 | + e = entry_new (ENTRY_DESKTOP, basename, filename, TRUE); | |
66 | ||
67 | categories = find_value (str, "Categories"); | |
68 | if (categories != NULL) | |
69 | @@ -1893,7 +1901,48 @@ | |
70 | entry_new_directory_from_file (const char *filename, | |
71 | const char *basename) | |
72 | { | |
73 | - return entry_new (ENTRY_DIRECTORY, basename, filename); | |
74 | + char *str; | |
75 | + gsize len; | |
76 | + GError *err; | |
77 | + Entry *e; | |
78 | + gboolean show; | |
79 | + | |
80 | + str = NULL; | |
81 | + len = 0; | |
82 | + err = NULL; | |
83 | + | |
84 | + if (!g_file_get_contents (filename, &str, &len, &err)) | |
85 | + { | |
86 | + menu_verbose ("Could not get contents of \"%s\": %s\n", | |
87 | + filename, err->message); | |
88 | + g_error_free (err); | |
89 | + return NULL; | |
90 | + } | |
91 | + | |
92 | + /* Check for NoDisplay */ | |
93 | + char *nodisplay; | |
94 | + | |
95 | + show = TRUE; | |
96 | + | |
97 | + nodisplay = find_value (str, "NoDisplay"); | |
98 | + | |
99 | + if (nodisplay != NULL) | |
100 | + if (strcasecmp (nodisplay, "True") == 0) | |
101 | + show = FALSE; | |
102 | + | |
103 | + if (!show) | |
104 | + menu_verbose ("Not showing \"%s\" due to NoDisplay=%s\n", | |
105 | + filename, nodisplay); | |
106 | + | |
107 | + g_free (nodisplay); | |
108 | + | |
109 | + /* End checking for NoDisplay */ | |
110 | + | |
111 | + e = entry_new (ENTRY_DIRECTORY, basename, filename, show); | |
112 | + | |
113 | + g_free (str); | |
114 | + | |
115 | + return e; | |
116 | } | |
117 | ||
118 | static void | |
119 | diff -urN aa/desktop-file-utils-0.7/src/menu-entries.h desktop-file-utils-0.7/src/menu-entries.h | |
120 | --- aa/desktop-file-utils-0.7/src/menu-entries.h 2004-07-28 15:19:30.491876240 +0200 | |
121 | +++ desktop-file-utils-0.7/src/menu-entries.h 2004-07-28 20:09:57.515565944 +0200 | |
122 | @@ -131,6 +131,7 @@ | |
123 | const char* entry_get_absolute_path (Entry *entry); | |
124 | const char* entry_get_relative_path (Entry *entry); | |
125 | const char* entry_get_name (Entry *entry); | |
126 | +gboolean entry_get_show (Entry *entry); | |
127 | gboolean entry_has_category (Entry *entry, | |
128 | EntryCache *cache, | |
129 | const char *category); | |
130 | diff -urN aa/desktop-file-utils-0.7/src/menu-process.c desktop-file-utils-0.7/src/menu-process.c | |
131 | --- aa/desktop-file-utils-0.7/src/menu-process.c 2004-07-28 15:19:30.501874720 +0200 | |
132 | +++ desktop-file-utils-0.7/src/menu-process.c 2004-07-28 21:42:52.369059392 +0200 | |
133 | @@ -1062,6 +1062,7 @@ | |
134 | GHashTable *allocated, | |
135 | const DesktopEntryTree *tree); | |
136 | static void remove_empty_submenus (TreeNode * node); | |
137 | +static void remove_no_display_submenus (TreeNode * node); | |
138 | static void process_only_unallocated (TreeNode *node, | |
139 | GHashTable *allocated); | |
140 | ||
141 | @@ -1238,6 +1239,7 @@ | |
142 | tree->root = new_node; | |
143 | process_only_unallocated (tree->root, allocated); | |
144 | remove_empty_submenus (tree->root); | |
145 | + remove_no_display_submenus(tree->root); | |
146 | ||
147 | /* Update the modification time for the tree, so the | |
148 | * panel knows to reload the VFS directory. | |
149 | @@ -2254,6 +2256,30 @@ | |
150 | } | |
151 | } | |
152 | ||
153 | +static void remove_no_display_submenus (TreeNode * node) | |
154 | +{ | |
155 | + GSList *subdir; | |
156 | + | |
157 | + subdir = node->subdirs; | |
158 | + while (subdir != NULL) | |
159 | + { | |
160 | + TreeNode *subdir_node = subdir->data; | |
161 | + GSList *next = subdir->next; | |
162 | + | |
163 | + if (subdir_node->dir_entry && | |
164 | + entry_get_show (subdir_node->dir_entry) == FALSE) | |
165 | + { | |
166 | + node->subdirs = g_slist_remove_link (node->subdirs, subdir); | |
167 | + tree_node_free (subdir_node); | |
168 | + } | |
169 | + else | |
170 | + remove_no_display_submenus (subdir_node); | |
171 | + | |
172 | + subdir = next; | |
173 | + } | |
174 | +} | |
175 | + | |
176 | + | |
177 | static void | |
178 | build_tree (DesktopEntryTree *tree) | |
179 | { | |
180 | @@ -2271,8 +2297,10 @@ | |
181 | if (tree->root) | |
182 | process_only_unallocated (tree->root, allocated); | |
183 | ||
184 | - if (tree->root) | |
185 | + if (tree->root){ | |
186 | remove_empty_submenus (tree->root); | |
187 | + remove_no_display_submenus (tree->root); | |
188 | + } | |
189 | ||
190 | g_hash_table_destroy (allocated); | |
191 |