diff options
author | William Hua <william.hua@canonical.com> | 2013-08-07 15:11:32 -0400 |
---|---|---|
committer | William Hua <william.hua@canonical.com> | 2013-08-07 15:11:32 -0400 |
commit | 0e3bb46532e1858f2cfee808bd66efa225cb2d94 (patch) | |
tree | f6b3017c096812b77d06b940aa5fb8e9465d6739 /lib/common.vala | |
parent | 6d780dde682d74aa61756ad95c05f5bb1bb57b01 (diff) | |
download | ayatana-indicator-keyboard-0e3bb46532e1858f2cfee808bd66efa225cb2d94.tar.gz ayatana-indicator-keyboard-0e3bb46532e1858f2cfee808bd66efa225cb2d94.tar.bz2 ayatana-indicator-keyboard-0e3bb46532e1858f2cfee808bd66efa225cb2d94.zip |
Split useful code into separate Source object.
Diffstat (limited to 'lib/common.vala')
-rw-r--r-- | lib/common.vala | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/common.vala b/lib/common.vala index 4d8b9add..9824bc26 100644 --- a/lib/common.vala +++ b/lib/common.vala @@ -16,18 +16,22 @@ * Authors: William Hua <william.hua@canonical.com> */ -string get_abbreviation (string name) { +string? abbreviate (string? name) { var index = 0; unichar first; unichar second; - if (name.get_next_char (ref index, out first)) { - if (name.get_next_char (ref index, out second)) { - return @"$((!) first.toupper ().to_string ())$((!) second.to_string ())"; + if (name != null) { + if (((!) name).get_next_char (ref index, out first)) { + if (((!) name).get_next_char (ref index, out second)) { + return @"$((!) first.toupper ().to_string ())$((!) second.to_string ())"; + } else { + return first.toupper ().to_string (); + } } else { - return (!) first.toupper ().to_string (); + return ""; } } else { - return ""; + return null; } } |