comparison src/editors.c @ 1278:c5852c543775

Add support for NoDisplay (entry is then hidden) and Type (only Application type is valid here) keys.
author zas_
date Tue, 03 Feb 2009 13:52:20 +0000
parents 4177057ca11b
children 8b89e3ff286b
comparison
equal deleted inserted replaced
1277:93df70312ccd 1278:c5852c543775
79 { 79 {
80 if (!editor) return; 80 if (!editor) return;
81 81
82 g_free(editor->key); 82 g_free(editor->key);
83 g_free(editor->name); 83 g_free(editor->name);
84 g_free(editor->icon);
84 g_free(editor->exec); 85 g_free(editor->exec);
85 g_free(editor->menu_path); 86 g_free(editor->menu_path);
86 g_free(editor->hotkey); 87 g_free(editor->hotkey);
87 string_list_free(editor->ext_list); 88 string_list_free(editor->ext_list);
88 g_free(editor->icon);
89 g_free(editor->file); 89 g_free(editor->file);
90 g_free(editor); 90 g_free(editor);
91 } 91 }
92 92
93 static GList *editor_mime_types_to_extensions(gchar **mime_types) 93 static GList *editor_mime_types_to_extensions(gchar **mime_types)
147 static gboolean editor_read_desktop_file(const gchar *path) 147 static gboolean editor_read_desktop_file(const gchar *path)
148 { 148 {
149 GKeyFile *key_file; 149 GKeyFile *key_file;
150 EditorDescription *editor; 150 EditorDescription *editor;
151 gchar *extensions; 151 gchar *extensions;
152 gchar *type;
152 const gchar *key = filename_from_path(path); 153 const gchar *key = filename_from_path(path);
153 gchar **categories, **only_show_in, **not_show_in; 154 gchar **categories, **only_show_in, **not_show_in;
154 gchar *try_exec; 155 gchar *try_exec;
155 156
156 if (g_hash_table_lookup(editors, key)) return FALSE; /* the file found earlier wins */ 157 if (g_hash_table_lookup(editors, key)) return FALSE; /* the file found earlier wins */
159 if (!g_key_file_load_from_file(key_file, path, 0, NULL)) 160 if (!g_key_file_load_from_file(key_file, path, 0, NULL))
160 { 161 {
161 g_key_file_free(key_file); 162 g_key_file_free(key_file);
162 return FALSE; 163 return FALSE;
163 } 164 }
165
166 type = g_key_file_get_string(key_file, DESKTOP_GROUP, "Type", NULL);
167 if (!type || strcmp(type, "Application") != 0)
168 {
169 /* We only consider desktop entries of Application type */
170 return FALSE;
171 }
164 172
165 editor = g_new0(EditorDescription, 1); 173 editor = g_new0(EditorDescription, 1);
166 174
167 editor->key = g_strdup(key); 175 editor->key = g_strdup(key);
168 editor->file = g_strdup(path); 176 editor->file = g_strdup(path);
169 177
170 g_hash_table_insert(editors, editor->key, editor); 178 g_hash_table_insert(editors, editor->key, editor);
171 179
172 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Hidden", NULL)) editor->hidden = TRUE; 180 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Hidden", NULL)
181 || g_key_file_get_boolean(key_file, DESKTOP_GROUP, "NoDisplay", NULL))
182 {
183 editor->hidden = TRUE;
184 }
173 185
174 categories = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "Categories", NULL, NULL); 186 categories = g_key_file_get_string_list(key_file, DESKTOP_GROUP, "Categories", NULL, NULL);
175 if (categories) 187 if (categories)
176 { 188 {
177 gboolean found = FALSE; 189 gboolean found = FALSE;