]> git.pld-linux.org Git - packages/desktop-file-utils.git/blob - desktop-file-utils-noshowin.patch
- 0.7, rel. 0.9, no problems detected with grzegol's menu stuff
[packages/desktop-file-utils.git] / desktop-file-utils-noshowin.patch
1 diff -urN aa/desktop-file-utils-0.6/src/menu-entries.c desktop-file-utils-0.6/src/menu-entries.c
2 --- aa/desktop-file-utils-0.6/src/menu-entries.c        2004-07-22 01:37:57.796843632 +0200
3 +++ desktop-file-utils-0.6/src/menu-entries.c   2004-07-23 00:12:03.519828512 +0200
4 @@ -1226,6 +1226,7 @@
5    int refcount;
6    CachedDir *root_dir;
7    char *only_show_in_name;
8 +  char *no_show_in_name;
9    GHashTable *atoms_by_name;
10    GHashTable *names_by_atom;
11    unsigned int next_atom;
12 @@ -1832,6 +1833,47 @@
13          }
14      }
15  
16 +  if (cache->no_show_in_name)
17 +    {
18 +      char *noshowin;
19 +
20 +      show = TRUE;
21 +      
22 +      noshowin = find_value (str, "NoShowIn");
23 +  
24 +      if (noshowin != NULL)
25 +        {
26 +          char **split;
27 +          int i;
28 +
29 +          split = string_list_from_desktop_value (noshowin);
30 +          i = 0;
31 +          while (split[i] != NULL)
32 +            {
33 +              if (strcmp (split[i], cache->no_show_in_name) == 0)
34 +                {
35 +                  show = FALSE;
36 +                  break;
37 +                }
38 +                  
39 +              ++i;
40 +            }
41 +
42 +          if (!show)
43 +            menu_verbose ("Not showing \"%s\" due to NoShowIn=%s\n",
44 +                          filename, noshowin);
45 +          
46 +          g_strfreev (split);
47 +          g_free (noshowin);          
48 +        }
49 +
50 +      if (!show)
51 +        {
52 +          g_free (str);
53 +          return NULL;
54 +        }
55 +    }
56 +
57    e = entry_new (ENTRY_DESKTOP, basename, filename);
58    
59    categories = find_value (str, "Categories");
60 @@ -2258,6 +2300,7 @@
61        g_hash_table_destroy (cache->atoms_by_name);
62        
63        g_free (cache->only_show_in_name);
64 +      g_free (cache->no_show_in_name);
65        g_free (cache);
66      }
67  }
68 @@ -2276,6 +2319,21 @@
69    cache->only_show_in_name = g_strdup (name);
70  }
71  
72 +void
73 +entry_cache_set_no_show_in_name (EntryCache *cache,
74 +                                   const char *name)
75 +{
76 +  g_return_if_fail (cache != NULL);
77 +
78 +  /* Really you're screwed if you do this after stuff has
79 +   * already been loaded...
80 +   */
81 +  
82 +  g_free (cache->no_show_in_name);
83 +  cache->no_show_in_name = g_strdup (name);
84 +}
85 +
86 +
87  static void
88  cached_dir_invalidate (CachedDir *dir)
89  {
90 diff -urN aa/desktop-file-utils-0.6/src/menu-entries.h desktop-file-utils-0.6/src/menu-entries.h
91 --- aa/desktop-file-utils-0.6/src/menu-entries.h        2004-07-22 01:22:29.208010592 +0200
92 +++ desktop-file-utils-0.6/src/menu-entries.h   2004-07-23 00:03:18.085706640 +0200
93 @@ -60,6 +60,8 @@
94  void        entry_cache_unref                 (EntryCache *cache);
95  void        entry_cache_set_only_show_in_name (EntryCache *cache,
96                                                 const char *name);
97 +void        entry_cache_set_no_show_in_name   (EntryCache *cache,
98 +                                               const char *name);
99  void        entry_cache_invalidate            (EntryCache *cache,
100                                                 const char *dir);
101  
102 diff -urN aa/desktop-file-utils-0.6/src/menu-layout.c desktop-file-utils-0.6/src/menu-layout.c
103 --- aa/desktop-file-utils-0.6/src/menu-layout.c 2004-07-22 01:43:43.405303160 +0200
104 +++ desktop-file-utils-0.6/src/menu-layout.c    2004-07-23 00:06:03.359581192 +0200
105 @@ -1645,6 +1645,9 @@
106      case MENU_NODE_MENU_ONLY_SHOW_IN:
107        append_simple (node, depth, "OnlyShowIn", str);
108        break;
109 +    case MENU_NODE_MENU_NO_SHOW_IN:
110 +      append_simple (node, depth, "NoShowIn", str);
111 +      break;
112      case MENU_NODE_MENU_NO_DISPLAY:
113        append_simple (node, depth, "NoDisplay", str);
114        break;
115 diff -urN aa/desktop-file-utils-0.6/src/menu-layout.h desktop-file-utils-0.6/src/menu-layout.h
116 --- aa/desktop-file-utils-0.6/src/menu-layout.h 2004-07-22 01:43:10.477308976 +0200
117 +++ desktop-file-utils-0.6/src/menu-layout.h    2004-07-23 00:05:36.061731096 +0200
118 @@ -37,6 +37,7 @@
119    MENU_NODE_PASSTHROUGH,
120    MENU_NODE_MENU,
121    MENU_NODE_MENU_ONLY_SHOW_IN,
122 +  MENU_NODE_MENU_NO_SHOW_IN,
123    MENU_NODE_MENU_NO_DISPLAY,
124    MENU_NODE_APP_DIR,
125    MENU_NODE_DEFAULT_APP_DIRS,
126 diff -urN aa/desktop-file-utils-0.6/src/menu-method.c desktop-file-utils-0.6/src/menu-method.c
127 --- aa/desktop-file-utils-0.6/src/menu-method.c 2004-07-22 01:22:29.218009072 +0200
128 +++ desktop-file-utils-0.6/src/menu-method.c    2004-07-23 00:00:32.837828136 +0200
129 @@ -747,6 +747,7 @@
130  {
131          desktop_entry_tree_diradd_callback_set (directory_add_callback);
132          desktop_set_only_show_in ("GNOME");
133 +        desktop_set_no_show_in ("GNOME");
134          return &vtable;
135  }
136  
137 diff -urN aa/desktop-file-utils-0.6/src/menu-parser.c desktop-file-utils-0.6/src/menu-parser.c
138 --- aa/desktop-file-utils-0.6/src/menu-parser.c 2004-07-22 01:45:04.482977480 +0200
139 +++ desktop-file-utils-0.6/src/menu-parser.c    2004-07-23 00:06:54.961736472 +0200
140 @@ -338,6 +338,10 @@
141          {
142            push_node (parser, MENU_NODE_MENU_ONLY_SHOW_IN);
143          }
144 +      if (ELEMENT_IS ("NoShowIn"))
145 +        {
146 +          push_node (parser, MENU_NODE_MENU_NO_SHOW_IN);
147 +        }
148                         else if (ELEMENT_IS ("NoDisplay"))
149          {
150            push_node (parser, MENU_NODE_MENU_NO_DISPLAY);
151 @@ -789,6 +793,7 @@
152    switch (menu_node_get_type (parser->stack_top))
153      {
154      case MENU_NODE_MENU_ONLY_SHOW_IN:
155 +    case MENU_NODE_MENU_NO_SHOW_IN:
156      case MENU_NODE_MENU_NO_DISPLAY:
157      case MENU_NODE_APP_DIR:
158      case MENU_NODE_DIRECTORY_DIR:
159 @@ -878,6 +883,7 @@
160    switch (menu_node_get_type (parser->stack_top))
161      {
162      case MENU_NODE_MENU_ONLY_SHOW_IN:
163 +    case MENU_NODE_MENU_NO_SHOW_IN:
164      case MENU_NODE_MENU_NO_DISPLAY:
165      case MENU_NODE_APP_DIR:
166      case MENU_NODE_DIRECTORY_DIR:
167 diff -urN aa/desktop-file-utils-0.6/src/menu-process.c desktop-file-utils-0.6/src/menu-process.c
168 --- aa/desktop-file-utils-0.6/src/menu-process.c        2004-07-22 01:49:07.279066864 +0200
169 +++ desktop-file-utils-0.6/src/menu-process.c   2004-07-23 00:08:59.312832232 +0200
170 @@ -38,6 +38,11 @@
171   */
172  static char *    only_show_in_desktop = NULL;
173  
174 +/* Global NoShowIn variable, works for both
175 + * DesktopEntryTrees and Menus.
176 + */
177 +static char *    no_show_in_desktop = NULL;
178 +
179  static void      menu_node_resolve_files            (MenuCache  *menu_cache,
180                                                       EntryCache *entry_cache,
181                                                       MenuNode   *node);
182 @@ -1103,6 +1108,10 @@
183    if (only_show_in_desktop)
184      entry_cache_set_only_show_in_name (entry_cache,
185                                         only_show_in_desktop);
186 +       
187 +  if (no_show_in_desktop)
188 +    entry_cache_set_no_show_in_name (entry_cache,
189 +                                       no_show_in_desktop);
190    
191    resolved_node = menu_node_deep_copy (orig_node);
192    menu_node_resolve_files (menu_cache, entry_cache, resolved_node);
193 @@ -1995,6 +2004,14 @@
194            }
195            break;
196  
197 +        case MENU_NODE_MENU_NO_SHOW_IN:
198 +          {
199 +            if (no_show_in_desktop)
200 +              if (strcmp (no_show_in_desktop, menu_node_get_content (child)) == 0)
201 +                  deleted = TRUE;
202 +          }
203 +          break;
204 +
205          case MENU_NODE_MENU_NO_DISPLAY:
206            {
207              if (strcasecmp (menu_node_get_content (child), "True") == 0)
208 @@ -3262,3 +3279,12 @@
209  
210    only_show_in_desktop = g_strdup (only_show_in);
211  }
212 +
213 +void
214 +desktop_set_no_show_in (const char *no_show_in)
215 +{
216 +  if (no_show_in_desktop)
217 +    g_free (no_show_in_desktop);
218 +
219 +  no_show_in_desktop = g_strdup (no_show_in);
220 +}
221 diff -urN aa/desktop-file-utils-0.6/src/menu-process.h desktop-file-utils-0.6/src/menu-process.h
222 --- aa/desktop-file-utils-0.6/src/menu-process.h        2004-07-22 01:22:29.209010440 +0200
223 +++ desktop-file-utils-0.6/src/menu-process.h   2004-07-22 23:59:56.010426752 +0200
224 @@ -174,4 +174,7 @@
225  /* Set OnlyShowIn globally */
226  void        desktop_set_only_show_in (const char *only_show_in);
227  
228 +/* Set NoShowIn globally */
229 +void        desktop_set_no_show_in (const char *no_show_in);
230 +
231  #endif /* MENU_PROCESS_H */
This page took 0.121868 seconds and 3 git commands to generate.