[caribou] abolish margin and use align
- From: Eitan Isaacson <eitani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [caribou] abolish margin and use align
- Date: Wed, 22 Jun 2011 18:45:13 +0000 (UTC)
commit 0fc37c5a73d96400ffe8997399224fa831c7009b
Author: Eitan Isaacson <eitan monotonous org>
Date: Wed Jun 15 15:05:30 2011 -0700
abolish margin and use align
data/layouts/touch/ara.xml | 36 ++++++++++++++--------------
data/layouts/touch/il.xml | 36 ++++++++++++++--------------
data/layouts/touch/us.xml | 48 +++++++++++++++++++-------------------
libcaribou/key-model.vala | 2 +-
libcaribou/level-model.vala | 19 ++------------
libcaribou/row-model.vala | 19 ++------------
libcaribou/xml-deserializer.vala | 41 +++++++++++++++++++------------
7 files changed, 92 insertions(+), 109 deletions(-)
---
diff --git a/data/layouts/touch/ara.xml b/data/layouts/touch/ara.xml
index fc39a75..f8787ff 100644
--- a/data/layouts/touch/ara.xml
+++ b/data/layouts/touch/ara.xml
@@ -14,8 +14,8 @@
<key name="Arabic_jeem"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="Arabic_sheen"/>
+ <row align="center">
+ <key name="Arabic_sheen"/>
<key name="Arabic_seen"/>
<key name="Arabic_yeh"/>
<key name="Arabic_beh"/>
@@ -39,10 +39,10 @@
<key name="Return" width="2.0"/>
</row>
<row>
- <key name="Caribou_Symbols" toggle="symbols1" width="2.0"/>
- <key name="Arabic_fathatan"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key align="left" name="Caribou_Symbols" toggle="symbols1" width="2.0"/>
+ <key align="left" name="Arabic_fathatan"/>
+ <key align="left" name="space" width="5.0"/>
+ <key align="right" name="Caribou_Prefs"/>
</row>
</level>
<level mode="locked" name="symbols1">
@@ -59,8 +59,8 @@
<key name="Arabic_0"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="minus"/>
+ <row align="center">
+ <key name="minus"/>
<key name="slash"/>
<key name="colon"/>
<key name="Arabic_semicolon"/>
@@ -84,10 +84,10 @@
<key name="numbersign"/>
</row>
<row>
- <key name="Caribou_Alpha" toggle="default" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key align="left" name="Caribou_Alpha" toggle="default" width="2.0"/>
+ <key align="left" name="Caribou_Emoticons"/>
+ <key align="left" name="space" width="5.0"/>
+ <key align="right" name="Caribou_Prefs"/>
</row>
</level>
<level mode="locked" name="symbols2">
@@ -104,8 +104,8 @@
<key name="underscore"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="less"/>
+ <row align="center">
+ <key name="less"/>
<key name="greater"/>
<key name="asterisk"/>
<key name="semicolon"/>
@@ -129,10 +129,10 @@
<key name="numbersign"/>
</row>
<row>
- <key name="Caribou_Alpha" toggle="default" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key align="left" name="Caribou_Alpha" toggle="default" width="2.0"/>
+ <key align="left" name="Caribou_Emoticons"/>
+ <key align="left" name="space" width="5.0"/>
+ <key align="right" name="Caribou_Prefs"/>
</row>
</level>
</layout>
diff --git a/data/layouts/touch/il.xml b/data/layouts/touch/il.xml
index 524040c..49f766b 100644
--- a/data/layouts/touch/il.xml
+++ b/data/layouts/touch/il.xml
@@ -14,8 +14,8 @@
<key name="hebrew_pe"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="hebrew_shin"/>
+ <row align="center">
+ <key name="hebrew_shin"/>
<key name="hebrew_dalet"/>
<key name="hebrew_gimel"/>
<key name="hebrew_kaph"/>
@@ -39,10 +39,10 @@
<key name="Return" width="2.0"/>
</row>
<row>
- <key name="Caribou_Symbols" toggle="symbols1" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key name="Caribou_Symbols" align="left" toggle="symbols1" width="2.0"/>
+ <key name="Caribou_Emoticons" align="left"/>
+ <key name="space" width="5.0" align="left"/>
+ <key name="Caribou_Prefs" align="right"/>
</row>
</level>
<level mode="locked" name="symbols1">
@@ -59,8 +59,8 @@
<key name="0"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="minus"/>
+ <row align="right">
+ <key name="minus"/>
<key name="slash"/>
<key name="colon"/>
<key name="semicolon"/>
@@ -84,10 +84,10 @@
<key name="numbersign"/>
</row>
<row>
- <key name="Caribou_Alpha" toggle="default" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key name="Caribou_Alpha" toggle="default" width="2.0" align="left"/>
+ <key name="Caribou_Emoticons" align="left"/>
+ <key name="space" width="5.0" align="left"/>
+ <key name="Caribou_Prefs" align="right"/>
</row>
</level>
<level mode="locked" name="symbols2">
@@ -104,8 +104,8 @@
<key name="underscore"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="less"/>
+ <row align="right">
+ <key name="less"/>
<key name="greater"/>
<key name="asterisk"/>
<key name="semicolon"/>
@@ -129,10 +129,10 @@
<key name="numbersign"/>
</row>
<row>
- <key name="Caribou_Alpha" toggle="default" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key name="Caribou_Alpha" toggle="default" width="2.0" align="left"/>
+ <key name="Caribou_Emoticons" align="left"/>
+ <key name="space" width="5.0" align="left"/>
+ <key name="Caribou_Prefs" align="right"/>
</row>
</level>
</layout>
diff --git a/data/layouts/touch/us.xml b/data/layouts/touch/us.xml
index 0a9aaca..559bb69 100644
--- a/data/layouts/touch/us.xml
+++ b/data/layouts/touch/us.xml
@@ -42,8 +42,8 @@
<key name="p"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="a">
+ <row align="right">
+ <key name="a">
<key name="a"/>
<key name="agrave"/>
<key name="aacute"/>
@@ -81,10 +81,10 @@
<key name="question"/>
</row>
<row>
- <key name="Caribou_Symbols" toggle="symbols1" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key align="left" name="Caribou_Symbols" toggle="symbols1" width="2.0"/>
+ <key align="left" name="Caribou_Emoticons"/>
+ <key align="left" name="space" width="5.0"/>
+ <key align="right" name="Caribou_Prefs"/>
</row>
</level>
<level mode="latched" name="level2">
@@ -129,8 +129,8 @@
<key name="P"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="A">
+ <row align="right">
+ <key name="A">
<key name="A"/>
<key name="Agrave"/>
<key name="Aacute"/>
@@ -168,10 +168,10 @@
<key name="question"/>
</row>
<row>
- <key name="Caribou_Symbols" toggle="default" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key align="left" name="Caribou_Symbols" toggle="symbols1" width="2.0"/>
+ <key align="left" name="Caribou_Emoticons"/>
+ <key align="left" name="space" width="5.0"/>
+ <key align="right" name="Caribou_Prefs"/>
</row>
</level>
<level mode="locked" name="symbols1">
@@ -188,8 +188,8 @@
<key name="0"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="minus"/>
+ <row align="right">
+ <key name="minus"/>
<key name="slash"/>
<key name="colon"/>
<key name="semicolon"/>
@@ -219,10 +219,10 @@
<key name="numbersign"/>
</row>
<row>
- <key name="Caribou_Alpha" toggle="default" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key align="left" name="Caribou_Alpha" toggle="default" width="2.0"/>
+ <key align="left" name="Caribou_Emoticons"/>
+ <key align="left" name="space" width="5.0"/>
+ <key align="right" name="Caribou_Prefs"/>
</row>
</level>
<level mode="locked" name="symbols2">
@@ -239,8 +239,8 @@
<key name="underscore"/>
<key name="BackSpace"/>
</row>
- <row>
- <key margin-left="0.5" name="less"/>
+ <row align="right">
+ <key align="right" name="less"/>
<key name="greater"/>
<key name="asterisk"/>
<key name="semicolon"/>
@@ -264,10 +264,10 @@
<key name="numbersign"/>
</row>
<row>
- <key name="Caribou_Alpha" toggle="default" width="2.0"/>
- <key name="Caribou_Emoticons"/>
- <key name="space" width="5.0"/>
- <key margin-left="2.0" name="Caribou_Prefs"/>
+ <key align="left" name="Caribou_Alpha" toggle="default" width="2.0"/>
+ <key align="left" name="Caribou_Emoticons"/>
+ <key align="left" name="space" width="5.0"/>
+ <key align="right" name="Caribou_Prefs"/>
</row>
</level>
</layout>
diff --git a/libcaribou/key-model.vala b/libcaribou/key-model.vala
index da90c4f..7153bc6 100644
--- a/libcaribou/key-model.vala
+++ b/libcaribou/key-model.vala
@@ -2,7 +2,7 @@ using GLib;
namespace Caribou {
public class KeyModel : GLib.Object, IScannableItem, IKeyboardObject {
- public double margin_left { get; set; default = 0.0; }
+ public string align { get; set; default = "center"; }
public double width { get; set; default = 1.0; }
public string toggle { get; set; default = ""; }
diff --git a/libcaribou/level-model.vala b/libcaribou/level-model.vala
index 0d209d3..981a3c0 100644
--- a/libcaribou/level-model.vala
+++ b/libcaribou/level-model.vala
@@ -12,22 +12,9 @@ namespace Caribou {
rows = new Gee.ArrayList<RowModel> ();
}
- internal void add_key (int rownum, int colnum, KeyModel key) {
- int rowindex = rownum;
- RowModel row = null;
-
- if (rownum < 0)
- rowindex = rows.size + rownum;
-
- if (rownum >= rows.size) {
- row = new RowModel ();
- row.key_activated.connect (on_key_activated);
- rows.add(row);
- } else {
- row = rows[rowindex];
- }
-
- row.add_key (colnum, key);
+ internal void add_row (RowModel row) {
+ row.key_activated.connect (on_key_activated);
+ rows.add(row);
}
public RowModel[] get_rows () {
diff --git a/libcaribou/row-model.vala b/libcaribou/row-model.vala
index 7aac08e..fcc4713 100644
--- a/libcaribou/row-model.vala
+++ b/libcaribou/row-model.vala
@@ -9,22 +9,9 @@ namespace Caribou {
columns = new Gee.ArrayList<ColumnModel> ();
}
- internal void add_key (int colnum, KeyModel key) {
- int colindex = colnum;
- ColumnModel column = null;
-
- if (colnum < 0)
- colindex = columns.size + colnum;
-
- if (colnum >= columns.size) {
- column = new ColumnModel ();
- column.key_activated.connect ((k) => { key_activated (k); });
- columns.add(column);
- } else {
- column = columns[colindex];
- }
-
- column.add_key (key);
+ internal void add_column (ColumnModel column) {
+ column.key_activated.connect ((k) => { key_activated (k); });
+ columns.add(column);
}
public ColumnModel[] get_columns () {
diff --git a/libcaribou/xml-deserializer.vala b/libcaribou/xml-deserializer.vala
index 4656f28..d56e22b 100644
--- a/libcaribou/xml-deserializer.vala
+++ b/libcaribou/xml-deserializer.vala
@@ -91,34 +91,40 @@ namespace Caribou {
public static void load_rows (LevelModel level, Xml.Node* node) {
assert (node->name == "level");
- int rownum = 0;
for (Xml.Node* i = node->children; i != null; i = i->next) {
if (i->type != ElementType.ELEMENT_NODE)
continue;
- int colnum = 0;
+ RowModel row = new RowModel ();
+ level.add_row (row);
+
for (Xml.Node* i2 = i->children; i2 != null; i2 = i2->next) {
- if (i2->name == "key")
- level.add_key (rownum, colnum, load_key(i2));
- else if (i2->name == "column")
- load_column (level, rownum, colnum++, i2);
+ if (i2->type != ElementType.ELEMENT_NODE)
+ continue;
+
+ if (i2->name == "key") {
+ load_column (row, i->get_prop ("align"), i);
+ break;
+ }
+
+ load_column (row, i2->get_prop ("align"), i2);
}
- rownum++;
}
}
- public static void load_column (LevelModel level, int row, int col,
- Xml.Node* node) {
- assert (node->name == "column");
+ public static void load_column (RowModel row, string? align, Xml.Node* node) {
+ ColumnModel column = new ColumnModel ();
+ row.add_column (column);
+
for (Xml.Node* i = node->children; i != null; i = i->next) {
if (i->type != ElementType.ELEMENT_NODE)
continue;
-
- level.add_key (row, col, load_key (i));
+
+ column.add_key (load_key (i, align));
}
}
- public static KeyModel load_key (Xml.Node* node) {
+ public static KeyModel load_key (Xml.Node* node, string? align) {
assert (node->name == "key");
string name = node->get_prop ("name");
@@ -126,11 +132,14 @@ namespace Caribou {
KeyModel key = new KeyModel (name);
+ if (align != null)
+ key.align = align;
+
for (Attr* prop = node->properties; prop != null; prop = prop->next) {
if (prop->name == "toggle")
key.toggle = prop->children->content;
- else if (prop->name == "margin-left")
- key.margin_left = double.parse (prop->children->content);
+ else if (prop->name == "align")
+ key.align = prop->children->content;
else if (prop->name == "width")
key.width = double.parse (prop->children->content);
}
@@ -139,7 +148,7 @@ namespace Caribou {
if (i->type != ElementType.ELEMENT_NODE)
continue;
- key.add_subkey (load_key (i));
+ key.add_subkey (load_key (i, null));
}
return key;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]