| 1 |
/* |
| 2 |
* Copyright (c) 2017-2019 José Amuedo (https://github.com/spheras) |
| 3 |
* |
| 4 |
* This program is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 3 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
/** |
| 19 |
* @class |
| 20 |
* Item Settings |
| 21 |
*/ |
| 22 |
public class DesktopFolder.ItemSettings : Object { |
| 23 |
/** the name of the item*/ |
| 24 |
public string name { get; set; } |
| 25 |
/** x position */ |
| 26 |
public int x { get; set; } |
| 27 |
/** y position */ |
| 28 |
public int y { get; set; } |
| 29 |
/** the icon for this file */ |
| 30 |
public string icon { get; set; } |
| 31 |
|
| 32 |
/** |
| 33 |
* @constructor |
| 34 |
*/ |
| 35 |
public ItemSettings () { |
| 36 |
this.name = "helloWorld.txt"; |
| 37 |
this.x = 5; |
| 38 |
this.x = 5; |
| 39 |
this.icon = ""; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* @name to_string |
| 44 |
* @description convert to string the item |
| 45 |
*/ |
| 46 |
public string to_string () { |
| 47 |
return "%s;%d;%d;%s".printf (this.name, this.x, this.y, this.icon); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* @name parse |
| 52 |
* @description parse an string to create an ItemSettings object |
| 53 |
* @param data string the data to be parsed |
| 54 |
* @return ItemSettings the ItemSettings created |
| 55 |
*/ |
| 56 |
public static ItemSettings parse (string data) { |
| 57 |
ItemSettings result = new ItemSettings (); |
| 58 |
string[] split = data.split (";"); |
| 59 |
result.name = split[0]; |
| 60 |
result.x = int.parse (split[1]); |
| 61 |
result.y = int.parse (split[2]); |
| 62 |
if (split.length > 3) { |
| 63 |
result.icon = split[3]; |
| 64 |
} |
| 65 |
return result; |
| 66 |
} |
| 67 |
|
| 68 |
} |