1+ /*
2+ * Copyright (c) 2020-2026 (https://github.com/phase1geo/Annotator)
3+ *
4+ * This program is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2 of the License, or (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 GNU
12+ * General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public
15+ * License along with this program; if not, write to the
16+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17+ * Boston, MA 02110-1301 USA
18+ *
19+ * Authored by: Trevor Williams <phase1geo@gmail.com>
20+ */
21+
122using Gtk ;
223using Cairo ;
324
425public class CustomItem {
526
6- private static const int icon_size = 24 ;
27+ private const int icon_size = 24 ;
728
829 private Image ? _light_image = null ;
930 private Image ? _dark_image = null ;
1031
1132 public CanvasItem ? item { get ; private set ; default = null ; }
1233
13- /* Default constructor */
34+ // -------------------------------------------------------------
35+ // Default constructor
1436 public CustomItem () {
1537 item = null ;
1638 _light_image = null ;
@@ -42,7 +64,7 @@ public class CustomItem {
4264 private void create_image ( bool light ) {
4365 if ( item != null ) {
4466 var snapshot = new Snapshot ();
45- var rect = Graphene . Rect . alloc ();
67+ var rect = Graphene . Rect ();
4668 rect. init( 0 , 0 , (float )icon_size, (float )icon_size );
4769 var ctx = snapshot. append_cairo( rect );
4870 var it = item. duplicate();
@@ -67,14 +89,16 @@ public class CustomItem {
6789 }
6890 }
6991
70- /* Saves this item as XML format */
92+ // -------------------------------------------------------------
93+ // Saves this item as XML format
7194 public Xml .Node * save () {
7295 Xml . Node * node = new Xml .Node ( null , " custom-item" );
7396 node- > add_child( item. save( 0 , null ) );
7497 return ( node );
7598 }
7699
77- /* Loads this item from XML format */
100+ // -------------------------------------------------------------
101+ // Loads this item from XML format
78102 public void load ( Xml .Node * node , CanvasItems canvas_items ) {
79103 for ( Xml . Node * it= node- > children; it!= null ; it= it- > next ) {
80104 if ( (it- > type == Xml . ElementType . ELEMENT_NODE ) && (it- > name == " item" ) ) {
0 commit comments