aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hua <william.hua@canonical.com>2013-06-21 16:23:18 -0400
committerWilliam Hua <william.hua@canonical.com>2013-06-21 16:23:18 -0400
commitbba9546d3b6270348f3dba1d9788782182536035 (patch)
treeb786c9de026145daebce66974dc3b923859c160f
parentb7c785a8f7b5c071c6a55419286cb24d19735331 (diff)
downloadayatana-indicator-keyboard-bba9546d3b6270348f3dba1d9788782182536035.tar.gz
ayatana-indicator-keyboard-bba9546d3b6270348f3dba1d9788782182536035.tar.bz2
ayatana-indicator-keyboard-bba9546d3b6270348f3dba1d9788782182536035.zip
Icon generator enable experimental non-null.
-rw-r--r--data/Makefile.am3
-rw-r--r--data/main.vala34
-rw-r--r--lib/common.vala4
3 files changed, 23 insertions, 18 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index aadd619c..f9720a95 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,6 +1,7 @@
AM_CFLAGS = -DGNOME_DESKTOP_USE_UNSTABLE_API
AM_LDFLAGS = -lm
-AM_VALAFLAGS = --metadatadir $(top_srcdir)/deps \
+AM_VALAFLAGS = --enable-experimental-non-null \
+ --metadatadir $(top_srcdir)/deps \
--vapidir $(top_srcdir)/deps
noinst_PROGRAMS = indicator-keyboard-icon-generator
diff --git a/data/main.vala b/data/main.vala
index dec6e6cf..ead0edd5 100644
--- a/data/main.vala
+++ b/data/main.vala
@@ -10,9 +10,9 @@ int main (string[] args) {
var weight = 500;
var layout_size = 12;
var subscript_size = 8;
- string output_path = null;
- string no_subscript_path = null;
- string with_subscript_path = null;
+ string? output_path = null;
+ string? no_subscript_path = null;
+ string? with_subscript_path = null;
OptionEntry[] options = new OptionEntry[15];
options[0] = { "force", 'f', 0, OptionArg.NONE, ref force, "Overwrite existing files" };
@@ -29,7 +29,7 @@ int main (string[] args) {
options[11] = { "output", 'o', 0, OptionArg.FILENAME, ref output_path, "Output directory", "PATH" };
options[12] = { "no-subscript", 'i', 0, OptionArg.FILENAME, ref no_subscript_path, "Icon template", "PATH" };
options[13] = { "with-subscript", 'I', 0, OptionArg.FILENAME, ref with_subscript_path, "Subscript icon template", "PATH" };
- options[14] = { null };
+ options[14] = { };
try {
var context = new OptionContext ("- generate keyboard layout icons");
@@ -51,7 +51,7 @@ int main (string[] args) {
}
if (output_path != null) {
- var file = File.new_for_path (output_path);
+ var file = File.new_for_path ((!) output_path);
if (!file.query_exists (null)) {
try {
@@ -72,16 +72,20 @@ int main (string[] args) {
var occurrences = new Gee.HashMap <string, int> ();
layouts.foreach ((name) => {
- string short_name;
+ string? short_name;
info.get_layout_info (name, null, out short_name, null, null);
- var abbreviation = get_abbreviation (short_name);
+ if (short_name != null) {
+ var abbreviation = get_abbreviation ((!) short_name);
- if (!occurrences.has_key (abbreviation)) {
- occurrences[abbreviation] = 1;
- } else {
- occurrences[abbreviation] = occurrences[abbreviation] + 1;
+ if (abbreviation.get_char () != '\0') {
+ if (!occurrences.has_key (abbreviation)) {
+ occurrences[abbreviation] = 1;
+ } else {
+ occurrences[abbreviation] = occurrences[abbreviation] + 1;
+ }
+ }
}
});
@@ -96,7 +100,7 @@ int main (string[] args) {
var layout_font = @"font-family:$font;font-weight:$weight;font-size:$layout_size";
var subscript_font = @"font-family:$font;font-weight:$weight;font-size:$subscript_size";
- File.new_for_path (no_subscript_path).load_contents (null, out contents, null);
+ File.new_for_path ((!) no_subscript_path).load_contents (null, out contents, null);
no_subscript_data = (string) contents;
no_subscript_data = no_subscript_data.replace ("@WIDTH@", @"$width");
no_subscript_data = no_subscript_data.replace ("@HEIGHT@", @"$height");
@@ -109,7 +113,7 @@ int main (string[] args) {
no_subscript_data = no_subscript_data.replace ("@LAYOUT_FONT@", layout_font);
no_subscript_data = no_subscript_data.replace ("@SUBSCRIPT_FONT@", subscript_font);
- File.new_for_path (with_subscript_path).load_contents (null, out contents, null);
+ File.new_for_path ((!) with_subscript_path).load_contents (null, out contents, null);
with_subscript_data = (string) contents;
with_subscript_data = with_subscript_data.replace ("@WIDTH@", @"$width");
with_subscript_data = with_subscript_data.replace ("@HEIGHT@", @"$height");
@@ -145,7 +149,7 @@ int main (string[] args) {
foreach (var entry in occurrences.entries) {
var layout = entry.key;
var count = entry.value;
- var file = File.new_for_path (@"$output_path/indicator-keyboard-$layout.svg");
+ var file = File.new_for_path (@"$((!) output_path)/indicator-keyboard-$layout.svg");
if (force || !file.query_exists (null)) {
int layout_width;
@@ -188,7 +192,7 @@ int main (string[] args) {
partial_data = partial_data.replace ("@LAYOUT_Y@", @"$layout_y");
for (var i = 1; i <= count; i++) {
- file = File.new_for_path (@"$output_path/indicator-keyboard-$layout-$i.svg");
+ file = File.new_for_path (@"$((!) output_path)/indicator-keyboard-$layout-$i.svg");
if (force || !file.query_exists (null)) {
var subscript = @"$i";
diff --git a/lib/common.vala b/lib/common.vala
index 0e4e58e3..2c197c7b 100644
--- a/lib/common.vala
+++ b/lib/common.vala
@@ -5,9 +5,9 @@ string get_abbreviation (string name) {
if (name.get_next_char (ref index, out first)) {
if (name.get_next_char (ref index, out second)) {
- return @"$(first.toupper ())$second";
+ return @"$((!) first.toupper ().to_string ())$((!) second.to_string ())";
} else {
- return @"$(first.toupper ())";
+ return (!) first.toupper ().to_string ();
}
} else {
return "";