summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@gnome.org>2007-07-27 16:24:53 +0000
committerVincent Untz <vuntz@gnome.org>2007-07-27 16:24:53 +0000
commit9dec6ec674c88c9a8a6ab4aa9e71e3d9075faf22 (patch)
tree20d3dcb8e95203846b21f68aaacbf9e6863b674c
parent5052214fbc3702cbd9aa6911890b8bd155674fbd (diff)
new, checks that the value is either an absolute path to a file, or that
2007-07-27 Vincent Untz <vuntz@gnome.org> * src/validate.c: (handle_icon_key): new, checks that the value is either an absolute path to a file, or that the value looks like an icon name without an extension (png, xpm or svg). Rejects relative pathes too.
-rw-r--r--ChangeLog7
-rw-r--r--src/validate.c52
2 files changed, 58 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7c7df05..ab45fb5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-27 Vincent Untz <vuntz@gnome.org>
+
+ * src/validate.c: (handle_icon_key): new, checks that the value is
+ either an absolute path to a file, or that the value looks like an
+ icon name without an extension (png, xpm or svg). Rejects relative
+ pathes too.
+
2007-07-08 Vincent Untz <vuntz@gnome.org>
* src/install.c: (process_one_file): pass the GError to
diff --git a/src/validate.c b/src/validate.c
index e07c8cf..6fa1da6 100644
--- a/src/validate.c
+++ b/src/validate.c
@@ -167,6 +167,10 @@ handle_comment_key (kf_validator *kf,
const char *locale_key,
const char *value);
static gboolean
+handle_icon_key (kf_validator *kf,
+ const char *locale_key,
+ const char *value);
+static gboolean
handle_show_in_key (kf_validator *kf,
const char *locale_key,
const char *value);
@@ -267,7 +271,7 @@ struct {
{ DESKTOP_LOCALESTRING_TYPE, "GenericName", FALSE, FALSE, FALSE, NULL },
{ DESKTOP_BOOLEAN_TYPE, "NoDisplay", FALSE, FALSE, FALSE, NULL },
{ DESKTOP_LOCALESTRING_TYPE, "Comment", FALSE, FALSE, FALSE, handle_comment_key },
- { DESKTOP_LOCALESTRING_TYPE, "Icon", FALSE, FALSE, FALSE, NULL },
+ { DESKTOP_LOCALESTRING_TYPE, "Icon", FALSE, FALSE, FALSE, handle_icon_key },
{ DESKTOP_BOOLEAN_TYPE, "Hidden", FALSE, FALSE, FALSE, NULL },
{ DESKTOP_STRING_LIST_TYPE, "OnlyShowIn", FALSE, FALSE, FALSE, handle_show_in_key },
{ DESKTOP_STRING_LIST_TYPE, "NotShowIn", FALSE, FALSE, FALSE, handle_show_in_key },
@@ -698,6 +702,52 @@ handle_comment_key (kf_validator *kf,
return TRUE;
}
+/* + If the name is an absolute path, the given file will be used.
+ * Checked.
+ * + If the name is not an absolute path, the algorithm described in the Icon
+ * Theme Specification will be used to locate the icon.
+ * Checked.
+ * FIXME: add clarification to desktop entry spec that the name doesn't
+ * contain an extension
+ */
+static gboolean
+handle_icon_key (kf_validator *kf,
+ const char *locale_key,
+ const char *value)
+{
+ if (g_path_is_absolute (value)) {
+ if (g_str_has_suffix (value, "/")) {
+ print_fatal (kf, "value \"%s\" for key \"%s\" in group \"%s\" is an "
+ "absolute path to a directory, instead of being an "
+ "absolute path to an icon or an icon name\n",
+ value, locale_key, kf->current_group);
+ return FALSE;
+ } else
+ return TRUE;
+ }
+
+ if (strchr (value, '/')) {
+ print_fatal (kf, "value \"%s\" for key \"%s\" in group \"%s\" looks like "
+ "a relative path, instead of being an absolute path to "
+ "an icon or an icon name\n",
+ value, locale_key, kf->current_group);
+ return FALSE;
+ }
+
+ if (g_str_has_suffix (value, ".png") ||
+ g_str_has_suffix (value, ".xpm") ||
+ g_str_has_suffix (value, ".svg")) {
+ print_fatal (kf, "value \"%s\" for key \"%s\" in group \"%s\" is an icon "
+ "name with an extension, but there should be no extension "
+ "as described in the Icon Theme Specification if the "
+ "value is not an absolute path\n",
+ value, locale_key, kf->current_group);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* + Only one of these keys, either OnlyShowIn or NotShowIn, may appear in a
* group.
* Checked.