Skip to content

Commit 407027c

Browse files
committed
Checkpointing.
1 parent b527140 commit 407027c

19 files changed

Lines changed: 183 additions & 163 deletions

meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ cc = meson.get_compiler('c')
4141
math_dep = cc.find_library('m', required: false)
4242

4343
add_project_arguments([
44-
'--vapidir=' + join_paths(meson.current_source_dir(), 'vapi'),
45-
'--disable-warnings'
44+
'--vapidir=' + join_paths(meson.current_source_dir(), 'vapi')
45+
# '--disable-warnings'
4646
],
4747
language: 'vala',
4848
)

src/About.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class About {
3737
program_name = "Annotator",
3838
comments = _( "Image annotation application" ),
3939
copyright = _( "Copyright" ) + " © 2023-2026 Trevor Williams",
40-
version = Annotator.version,
40+
version = win.application.version,
4141
license_type = License.GPL_3_0,
4242
website = "https://appcenter.elementary.io/com.github.phase1geo.annotator/",
4343
website_label = _( "Annotator in AppCenter" ),

src/Application.vala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ public class Annotator : Gtk.Application {
3232
public static bool use_clipboard = false;
3333
public static bool take_screenshot = false;
3434
public static bool std_input = false;
35-
public static string version = "2.0.3";
3635

3736
public Annotator () {
3837

39-
Object( application_id: "com.github.phase1geo.annotator", flags: ApplicationFlags.HANDLES_OPEN );
38+
Object(
39+
application_id: "com.github.phase1geo.annotator",
40+
flags: ApplicationFlags.HANDLES_OPEN,
41+
version: "2.0.3"
42+
);
4043

4144
Intl.setlocale( LocaleCategory.ALL, "" );
4245
Intl.bindtextdomain( GETTEXT_PACKAGE, LOCALEDIR );

src/CanvasItems.vala

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -387,29 +387,34 @@ public class CanvasItems {
387387
add_item( item, -1, true );
388388
}
389389

390+
//-------------------------------------------------------------
391+
// Adds an image that the user can select from using a standard
392+
// file open dialog.
390393
public void add_image() {
391394

392-
// Get the file to open from the user
393-
var dialog = new FileChooserNative( _( "Open Insertion Image" ), _canvas.win, FileChooserAction.OPEN, _( "Open" ), _( "Cancel" ) );
394-
Utils.set_chooser_folder( dialog );
395-
396395
// Create file filters for each supported format
396+
var filters = new GLib.ListStore( typeof( FileFilter ) );
397397
foreach( FileFilter filter in _canvas.win.image_filters ) {
398-
dialog.add_filter( filter );
398+
filters.append( filter );
399399
}
400400

401-
dialog.response.connect((id) => {
402-
if( id == ResponseType.ACCEPT ) {
403-
var filename = dialog.get_file().get_path();
404-
var item = create_image( filename );
401+
// Get the file to open from the user
402+
var dialog = new FileDialog() {
403+
title = _( "Open Insertion Image" ),
404+
filters = filters
405+
};
406+
Utils.set_chooser_folder( dialog );
407+
408+
dialog.open.begin( _canvas.win, null, (obj, res) => {
409+
try {
410+
var file = dialog.open.end( res );
411+
var filename = file.get_path();
412+
var item = create_image( filename );
405413
add_item( item, -1, true );
406414
Utils.store_chooser_folder( filename );
407-
}
408-
dialog.destroy();
415+
} catch( Error e ) {}
409416
});
410417

411-
dialog.show();
412-
413418
}
414419

415420
//-------------------------------------------------------------
@@ -1217,7 +1222,7 @@ public class CanvasItems {
12171222
// Saves the given item as a custom item
12181223
private void do_save_custom( CanvasItem item ) {
12191224
var save_item = new CustomItem.with_item( item.duplicate() );
1220-
custom_items.add( save_item );
1225+
custom_items.add( _canvas.win, save_item );
12211226
}
12221227

12231228
//-------------------------------------------------------------

src/CanvasToolbar.vala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public class CanvasToolbar : Box {
486486
popover = new Popover(),
487487
child = make_color_icon()
488488
};
489-
mb.get_style_context().add_class( "color_chooser" );
489+
mb.add_css_class( "color_chooser" );
490490

491491
var box = new Box( Orientation.VERTICAL, 0 ) {
492492
margin_start = 10,
@@ -708,7 +708,7 @@ public class CanvasToolbar : Box {
708708
has_frame = false,
709709
popover = new Popover()
710710
};
711-
mb.get_style_context().add_class( "color_chooser" );
711+
mb.add_css_class( "color_chooser" );
712712

713713
_canvas.win.theme_changed.connect((dark_mode) => {
714714
mb.icon_name = dark_mode ? "font-annotator-dark-symbolic" : "font-annotator-symbolic";
@@ -805,7 +805,7 @@ public class CanvasToolbar : Box {
805805
private Image make_color_icon() {
806806

807807
var snapshot = new Snapshot();
808-
var rect = Graphene.Rect.alloc();
808+
var rect = Graphene.Rect();
809809
rect.init( 0, 0, (float)30, (float)24 );
810810
var ctx = snapshot.append_cairo( rect );
811811

@@ -842,7 +842,7 @@ public class CanvasToolbar : Box {
842842
var height = stroke_width;
843843

844844
var snapshot = new Snapshot();
845-
var rect = Graphene.Rect.alloc();
845+
var rect = Graphene.Rect();
846846
rect.init( 0, 0, (float)width, (float)height );
847847
var ctx = snapshot.append_cairo( rect );
848848

@@ -866,7 +866,7 @@ public class CanvasToolbar : Box {
866866
var height = 5;
867867

868868
var snapshot = new Snapshot();
869-
var rect = Graphene.Rect.alloc();
869+
var rect = Graphene.Rect();
870870
rect.init( 0, 0, (float)width, (float)height );
871871
var ctx = snapshot.append_cairo( rect );
872872

@@ -892,7 +892,7 @@ public class CanvasToolbar : Box {
892892
var height = _canvas.items.props.stroke_width.width();
893893

894894
var snapshot = new Snapshot();
895-
var rect = Graphene.Rect.alloc();
895+
var rect = Graphene.Rect();
896896
rect.init( 0, 0, (float)50, (float)height );
897897
var ctx = snapshot.append_cairo( rect );
898898

src/Clipboard.vala

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,36 @@ public class AnnotatorClipboard {
8585
var clipboard = Display.get_default().get_clipboard();
8686
var retval = false;
8787

88-
try {
89-
if( clipboard.get_formats().contain_mime_type( "image/png" ) ) {
90-
clipboard.read_texture_async.begin( null, (ob, res) => {
88+
if( clipboard.get_formats().contain_mime_type( "image/png" ) ) {
89+
clipboard.read_texture_async.begin( null, (ob, res) => {
90+
try {
9191
var texture = clipboard.read_texture_async.end( res );
9292
if( texture != null ) {
9393
var pixbuf = Utils.texture_to_pixbuf( texture );
9494
editor.paste_image( pixbuf, true );
9595
}
96-
});
97-
retval = true;
98-
} else if( !image_only && clipboard.get_formats().contain_mime_type( "application/xml" ) ) {
99-
clipboard.read_async.begin( {"application/xml"}, 0, null, (obj, res) => {
100-
string str;
96+
} catch( Error e ) {}
97+
});
98+
retval = true;
99+
} else if( !image_only && clipboard.get_formats().contain_mime_type( "application/xml" ) ) {
100+
clipboard.read_async.begin( {"application/xml"}, 0, null, (obj, res) => {
101+
string str;
102+
try {
101103
var stream = clipboard.read_async.end( res, out str );
102104
var contents = Utils.read_stream( stream );
103105
editor.paste_items( contents );
104-
});
105-
retval = true;
106-
} else if( !image_only && clipboard.get_formats().contain_gtype( Type.STRING ) ) {
107-
clipboard.read_text_async.begin( null, (obj, res) => {
106+
} catch( Error e ) {}
107+
});
108+
retval = true;
109+
} else if( !image_only && clipboard.get_formats().contain_gtype( Type.STRING ) ) {
110+
clipboard.read_text_async.begin( null, (obj, res) => {
111+
try {
108112
var text = clipboard.read_text_async.end( res );
109113
editor.paste_text( text );
110-
});
111-
retval = true;
112-
}
113-
} catch( Error e ) {}
114+
} catch( Error e ) {}
115+
});
116+
retval = true;
117+
}
114118

115119
return( retval );
116120

src/ColorPicker.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class ColorPicker : Box {
7272
has_frame = false
7373
};
7474
_toggle.toggled.connect( handle_toggle );
75-
_toggle.get_style_context().add_class( type.get_css_class() );
75+
_toggle.add_css_class( type.get_css_class() );
7676
type.set_image( _toggle );
7777

7878
_chooser = new ColorChooserWidget();

src/CustomItem.vala

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
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+
122
using Gtk;
223
using Cairo;
324

425
public 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

Comments
 (0)