Skip to content

Commit 0aa8386

Browse files
committed
* Adding GSettings schema and starting to integrate settings into the UI (window placement and sidebar are done).
* Checkpointing Animator changes (work in progress). * Adding GSettings.cmake file to handle the installation of the schema file. * Minor fixes.
1 parent fbacb97 commit 0aa8386

11 files changed

+248
-42
lines changed

CMakeCache.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ CMAKE_STRIP:FILEPATH=/usr/bin/strip
165165
// Studio IDE projects all commands are done without /nologo.
166166
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
167167

168+
//Compile GSettings Schemas after installation
169+
GSETTINGS_COMPILE:BOOL=ON
170+
171+
//Install GSettings Schemas locally instead of to the GLib prefix
172+
GSETTINGS_LOCALINSTALL:BOOL=ON
173+
168174
//Path to a program.
169175
INTLTOOL_EXTRACT_EXECUTABLE:FILEPATH=/usr/bin/intltool-extract
170176

@@ -384,7 +390,7 @@ DEPS_unity_LIBDIR:INTERNAL=/usr/lib/x86_64-linux-gnu
384390
DEPS_unity_PREFIX:INTERNAL=/usr
385391
DEPS_unity_VERSION:INTERNAL=7.1.4
386392
//Details about finding PkgConfig
387-
FIND_PACKAGE_MESSAGE_DETAILS_PkgConfig:INTERNAL=[/usr/bin/pkg-config][v0.29.1()]
393+
FIND_PACKAGE_MESSAGE_DETAILS_PkgConfig:INTERNAL=[pkg-config][v0.29.1()]
388394
//Details about finding Vala
389395
FIND_PACKAGE_MESSAGE_DETAILS_Vala:INTERNAL=[/usr/bin/valac][v()]
390396
//ADVANCED property for variable: PKG_CONFIG_EXECUTABLE

CMakeFiles/Makefile.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(CMAKE_MAKEFILE_DEPENDS
1111
"CMakeFiles/3.5.1/CMakeCXXCompiler.cmake"
1212
"CMakeFiles/3.5.1/CMakeSystem.cmake"
1313
"CMakeLists.txt"
14+
"cmake/GSettings.cmake"
1415
"po/CMakeLists.txt"
1516
"/usr/share/cmake-3.5/Modules/CMakeCInformation.cmake"
1617
"/usr/share/cmake-3.5/Modules/CMakeCXXInformation.cmake"

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ set (RELEASE_NAME "")
1919
set (VERSION "0.1")
2020
set (VERSION_INFO "")
2121

22+
# GSettings
23+
include(GSettings)
24+
add_schema( "data/com.github.phase1geo.minder.gschema.xml" )
25+
2226
# we're about to use pkgconfig to make sure dependencies are installed so let's find pkgconfig first
2327
find_package(PkgConfig)
2428

cmake/GSettings.cmake

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them.
2+
3+
option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" ON)
4+
5+
option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" ${GSETTINGS_LOCALINSTALL})
6+
7+
if(GSETTINGS_LOCALINSTALL)
8+
message(STATUS "GSettings schemas will be installed locally.")
9+
endif()
10+
11+
if(GSETTINGS_COMPILE)
12+
message(STATUS "GSettings shemas will be compiled.")
13+
endif()
14+
15+
macro(add_schema SCHEMA_NAME)
16+
17+
set(PKG_CONFIG_EXECUTABLE pkg-config)
18+
# Have an option to not install the schema into where GLib is
19+
if (GSETTINGS_LOCALINSTALL)
20+
SET (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/")
21+
else (GSETTINGS_LOCALINSTALL)
22+
execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} glib-2.0 --variable prefix OUTPUT_VARIABLE _glib_prefix OUTPUT_STRIP_TRAILING_WHITESPACE)
23+
SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/")
24+
endif (GSETTINGS_LOCALINSTALL)
25+
26+
# Run the validator and error if it fails
27+
execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
28+
execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
29+
30+
if (_schemas_invalid)
31+
message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
32+
endif (_schemas_invalid)
33+
34+
# Actually install and recomple schemas
35+
message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
36+
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
37+
38+
if (GSETTINGS_COMPILE)
39+
install (CODE "message (STATUS \"Compiling GSettings schemas\")")
40+
install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})")
41+
endif ()
42+
endmacro()

cmake_install.cmake

+20
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
3232
set(CMAKE_INSTALL_SO_NO_EXE "1")
3333
endif()
3434

35+
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
36+
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
37+
"/usr/share/glib-2.0/schemas/com.github.phase1geo.minder.gschema.xml")
38+
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
39+
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
40+
endif()
41+
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
42+
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
43+
endif()
44+
file(INSTALL DESTINATION "/usr/share/glib-2.0/schemas" TYPE FILE OPTIONAL FILES "/home/trevorw/projects/Minder/data/com.github.phase1geo.minder.gschema.xml")
45+
endif()
46+
47+
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
48+
message (STATUS "Compiling GSettings schemas")
49+
endif()
50+
51+
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
52+
execute_process (COMMAND /usr/lib/x86_64-linux-gnu/glib-2.0/glib-compile-schemas /usr/share/glib-2.0/schemas/)
53+
endif()
54+
3555
if(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
3656
if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/com.github.phase1geo.minder" AND
3757
NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/com.github.phase1geo.minder")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<schemalist>
3+
<schema path="/com/github/phase1geo/minder/" id="com.github.phase1geo.minder" gettext-domain="com.github.phase1geo.minder">
4+
<key name="window-x" type="i">
5+
<default>-1</default>
6+
<summary>Most recent x position of minder window</summary>
7+
<description>Most recent x position of minder window</description>
8+
</key>
9+
<key name="window-y" type="i">
10+
<default>-1</default>
11+
<summary>Most recent y position of minder window</summary>
12+
<description>Most recent y position of minder window</description>
13+
</key>
14+
<key name="window-w" type="i">
15+
<default>1000</default>
16+
<summary>Most recent width of minder window</summary>
17+
<description>Most recent width of minder window</description>
18+
</key>
19+
<key name="window-h" type="i">
20+
<default>800</default>
21+
<summary>Most recent height of minder window</summary>
22+
<description>Most recent height of minder window</description>
23+
</key>
24+
<key name="scale-factor" type="d">
25+
<default>1.0</default>
26+
<summary>Most recent scaling factor used in canvas</summary>
27+
<description>Most recent scaling factor used in canvas</description>
28+
</key>
29+
<key name="origin-x" type="d">
30+
<default>0.0</default>
31+
<summary>Most recent canvas x origin used in canvas</summary>
32+
<description>Most recent canvas x origin used in canvas</description>
33+
</key>
34+
<key name="origin-y" type="d">
35+
<default>0.0</default>
36+
<summary>Most recent canvas y origin used in canvas</summary>
37+
<description>Most recent canvas y origin used in canvas</description>
38+
</key>
39+
<key name="nodes" type="s">
40+
<default>""</default>
41+
<summary>XML listing of the currently stored nodes</summary>
42+
<description>XML listing of the currently stored nodes</description>
43+
</key>
44+
<key name="layout" type="s">
45+
<default>"Horizontal"</default>
46+
<summary>Most recent layout in use</summary>
47+
<description>Most recent layout in use</description>
48+
</key>
49+
<key name="theme" type="s">
50+
<default>"Default"</default>
51+
<summary>Most recent theme in use</summary>
52+
<description>Most recent theme in use</description>
53+
</key>
54+
<key name="node-properties-shown" type="b">
55+
<default>false</default>
56+
<summary>Most recent state of the node properties sidebar</summary>
57+
<description>Most recent state of the node properties sidebar</description>
58+
</key>
59+
<key name="map-properties-shown" type="b">
60+
<default>false</default>
61+
<summary>Most recent state of the map properties sidebar</summary>
62+
<description>Most recent state of the map properties sidebar</description>
63+
</key>
64+
</schema>
65+
</schemalist>

install_manifest.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/usr/share/glib-2.0/schemas/com.github.phase1geo.minder.gschema.xml
12
/usr/bin/com.github.phase1geo.minder
23
/usr/share/applications/com.github.phase1geo.minder.desktop
34
/usr/share/metainfo/com.github.phase1geo.minder.appdata.xml

src/Animator.vala

+39-22
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,40 @@ public class Animator : Object {
3434
private double? _eox = null; // Ending x-origin
3535
private double? _eoy = null; // Ending y-origin
3636
private int _index = 1; // Animation index
37-
private const int _timeout = 20; // Number of milliseconds between frames
37+
private string _name = "";
38+
private int _id;
39+
// private const int _timeout = 20; // Number of milliseconds between frames (30 fps)
40+
private const int _timeout = 1000; // Number of milliseconds between frames (30 fps)
3841
private const double _frames = 10; // Number of frames to animate (note: set to 1 to disable animation)
42+
private static int _next_id = 0;
43+
44+
public static bool _in_progress = false;
3945

4046
/* Default constructor */
41-
public Animator( DrawArea da ) {
47+
public Animator( DrawArea da, string name = "unnamed" ) {
4248
_da = da;
49+
_name = name;
50+
_id = _next_id++;
4351
_da.stop_animation();
4452
_spos = new AnimationPositions( _da );
4553
}
4654

4755
/* Constructor for a specified node tree */
48-
public Animator.node( DrawArea da, Node n ) {
56+
public Animator.node( DrawArea da, Node n, string name = "unnamed" ) {
4957
_da = da;
58+
_name = name;
59+
_id = _next_id++;
5060
_da.stop_animation();
5161
_node = n;
5262
_spos = new AnimationPositions.for_node( _node );
5363
_index = 0;
5464
}
5565

5666
/* Constructor for a scale change */
57-
public Animator.scale( DrawArea da ) {
67+
public Animator.scale( DrawArea da, string name = "unnamed" ) {
5868
_da = da;
69+
_name = name;
70+
_id = _next_id++;
5971
_da.stop_animation();
6072
_sscale = da.get_scale_factor();
6173
_da.get_origin( out _sox, out _soy );
@@ -66,32 +78,33 @@ public class Animator : Object {
6678
_da.stop_animation.connect( stop_animating );
6779
if( _node != null ) {
6880
_epos = new AnimationPositions.for_node( _node );
69-
animate_positions();
81+
Timeout.add( _timeout, animate_positions );
7082
} else if( _sscale != null ) {
7183
_escale = _da.get_scale_factor();
7284
_da.get_origin( out _eox, out _eoy );
73-
animate_scaling();
85+
Timeout.add( _timeout, animate_scaling );
7486
} else {
7587
_epos = new AnimationPositions( _da );
76-
animate_positions();
88+
Timeout.add( _timeout, animate_positions );
7789
}
7890
}
7991

8092
/* Perform the animation */
8193
private bool animate_positions() {
8294
double divisor = _index / _frames;
8395
_index++;
84-
for( int i=0; i<_spos.length; i++ ) {
96+
for( int i=0; i<_spos.length(); i++ ) {
8597
double x = _spos.x( i ) + ((_epos.x( i ) - _spos.x( i )) * divisor);
8698
double y = _spos.y( i ) + ((_epos.y( i ) - _spos.y( i )) * divisor);
8799
_spos.node( i ).set_posx_only( x );
88100
_spos.node( i ).set_posy_only( y );
89101
}
90102
_da.queue_draw();
91-
if( _index <= _frames ) {
92-
Timeout.add( _timeout, this.animate_positions );
103+
if( _index > _frames ) {
104+
_da.stop_animation.disconnect( stop_animating );
105+
return( false );
93106
}
94-
return( false );
107+
return( true );
95108
}
96109

97110
/* Animates the given scaling and origin changes */
@@ -101,19 +114,25 @@ public class Animator : Object {
101114
double scale_factor = _sscale + ((_escale - _sscale) * divisor);
102115
double origin_x = _sox + ((_eox - _sox) * divisor);
103116
double origin_y = _soy + ((_eoy - _soy) * divisor);
117+
stdout.printf( "index: %d, divisor: %g, scale: %g, ox: %g, oy: %g\n", _index, divisor, scale_factor, origin_x, origin_y );
104118
_da.set_scale_factor( scale_factor );
105119
_da.set_origin( origin_x, origin_y );
106120
_da.queue_draw();
107-
if( _index <= _frames ) {
108-
Timeout.add( _timeout, this.animate_scaling );
121+
if( _index > _frames ) {
122+
_da.stop_animation.disconnect( stop_animating );
123+
return( false );
109124
}
110-
return( false );
125+
return( true );
111126
}
112127

113128
/* Stops any active animations */
114129
private void stop_animating() {
115-
stdout.printf( "Stopping animation, index: %d\n", _index );
116130
_index = (int)_frames;
131+
if( _sscale != null ) {
132+
animate_scaling();
133+
} else {
134+
animate_positions();
135+
}
117136
}
118137

119138
}
@@ -128,13 +147,6 @@ public class AnimationPositions : Object {
128147
private Array<double?> _y;
129148
private Array<Node?> _node;
130149

131-
public uint length {
132-
private set {}
133-
get {
134-
return( _node.length );
135-
}
136-
}
137-
138150
/* Default constructor */
139151
public AnimationPositions( DrawArea da ) {
140152
_x = new Array<double?>();
@@ -166,6 +178,11 @@ public class AnimationPositions : Object {
166178
}
167179
}
168180

181+
/* Returns the number of nodes in this structure */
182+
public uint length() {
183+
return( _node.length );
184+
}
185+
169186
/* Returns the X position at the given index */
170187
public double x( int index ) {
171188
return( _x.index( index ) );

src/Application.vala

+16-1
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ public class Minder : Granite.Application {
3434

3535
protected override void activate() {
3636

37+
var settings = new GLib.Settings( "com.github.phase1geo.minder" );
38+
3739
/* Create the main window */
38-
var appwin = new MainWindow( this );
40+
var appwin = new MainWindow( this, settings );
3941

4042
/* Handle the command-line options */
4143
if( open_file != null ) {
@@ -49,6 +51,19 @@ public class Minder : Granite.Application {
4951
/* TBD - Load the last file */
5052
}
5153

54+
/* Handle any changes to the position of the window */
55+
appwin.configure_event.connect(() => {
56+
int root_x, root_y;
57+
int size_w, size_h;
58+
appwin.get_position( out root_x, out root_y );
59+
appwin.get_size( out size_w, out size_h );
60+
settings.set_int( "window-x", root_x );
61+
settings.set_int( "window-y", root_y );
62+
settings.set_int( "window-w", size_w );
63+
settings.set_int( "window-h", size_h );
64+
return( false );
65+
});
66+
5267
/* Run the main loop */
5368
Gtk.main();
5469

0 commit comments

Comments
 (0)