diff options
Diffstat (limited to 'src/ibusobservedpath.c')
-rw-r--r-- | src/ibusobservedpath.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/ibusobservedpath.c b/src/ibusobservedpath.c index 684cd77c..9d45d40f 100644 --- a/src/ibusobservedpath.c +++ b/src/ibusobservedpath.c @@ -1,8 +1,8 @@ /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ /* vim:set et sts=4: */ /* ibus - The Input IBus - * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> - * Copyright (C) 2008-2010 Red Hat, Inc. + * Copyright (C) 2008-2015 Peng Huang <shawn.p.huang@gmail.com> + * Copyright (C) 2008-2015 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -88,7 +88,8 @@ ibus_observed_path_serialize (IBusObservedPath *path, { gboolean retval; - retval = IBUS_SERIALIZABLE_CLASS (ibus_observed_path_parent_class)->serialize ((IBusSerializable *)path, builder); + retval = IBUS_SERIALIZABLE_CLASS (ibus_observed_path_parent_class)-> + serialize ((IBusSerializable *)path, builder); g_return_val_if_fail (retval, FALSE); g_variant_builder_add (builder, "s", path->path); @@ -103,7 +104,8 @@ ibus_observed_path_deserialize (IBusObservedPath *path, { gint retval; - retval = IBUS_SERIALIZABLE_CLASS (ibus_observed_path_parent_class)->deserialize ((IBusSerializable *)path, variant); + retval = IBUS_SERIALIZABLE_CLASS (ibus_observed_path_parent_class)-> + deserialize ((IBusSerializable *)path, variant); g_return_val_if_fail (retval, 0); ibus_g_variant_get_child_string (variant, retval++, &path->path); @@ -152,13 +154,25 @@ ibus_observed_path_output (IBusObservedPath *path, gboolean ibus_observed_path_check_modification (IBusObservedPath *path) { - g_assert (IBUS_IS_OBSERVED_PATH (path)); + gchar *real_path = NULL; struct stat buf; - if (g_stat (path->path, &buf) != 0) { + g_assert (IBUS_IS_OBSERVED_PATH (path)); + + if (path->path[0] == '~') { + const gchar *homedir = g_get_home_dir (); + real_path = g_build_filename (homedir, path->path + 2, NULL); + } + else { + real_path = g_strdup (path->path); + } + + if (g_stat (real_path, &buf) != 0) { buf.st_mtime = 0; } + g_free (real_path); + if (path->mtime == buf.st_mtime) return FALSE; return TRUE; @@ -237,15 +251,7 @@ ibus_observed_path_parse_xml_node (IBusObservedPath *path, return FALSE; } - if (node->text[0] == '~') { - const gchar *homedir = g_getenv ("HOME"); - if (homedir == NULL) - homedir = g_get_home_dir (); - path->path = g_build_filename (homedir, node->text + 2, NULL); - } - else { - path->path = g_strdup (node->text); - } + path->path = g_strdup (node->text); gchar **attr; for (attr = node->attributes; attr[0]; attr += 2) { |