[libgtkmusic] Fixed event signature. Build system improved (check for Vala version, shared library name fixed)



commit 0598c5e64249b538f2e95b50530b490ad9c29664
Author: Leandro Resende Mattioli <leandro mattioli gmail com>
Date:   Thu Jan 12 17:18:21 2017 -0200

    Fixed event signature. Build system improved (check for Vala version, shared library name fixed)

 CMakeLists.txt        |   28 +++++++++++++++++-----------
 INSTALL               |   10 ++++++++++
 gtkmusic.pc.in        |    2 +-
 src/GuitarWidget.vala |    8 ++++----
 src/PianoWidget.vala  |    8 ++++----
 test/TestsGuitar.vala |    3 +--
 test/TestsPiano.vala  |    3 +--
 7 files changed, 38 insertions(+), 24 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c668d6a..dc9bea9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,19 +20,20 @@ include(UseVala)
 
 set(AUTHOR_NAME "Leandro Resende Mattioli")
 set(AUTHOR_EMAIL "leandro mattioli gmail com")
-set(AUTHOR_CONTACT ${AUTHOR_NAME} <${AUTHOR_EMAIl}>)
+set(AUTHOR_CONTACT ${AUTHOR_NAME} <${AUTHOR_EMAIL}>)
 
 set(PROJECT_URL "https://wiki.gnome.org/Projects/libgtkmusic";)
 
 set(VERSION_MAJOR "0")
 set(VERSION_MINOR "4")
-set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR})
+set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) # Build Version
+set(SOVERSION ${VERSION_MAJOR})                # API Version
 
 include_directories(src)
 
-set(GIR_FILE GtkMusic-${VERSION_STRING}.gir)
-set(TYPELIB_FILE GtkMusic-${VERSION_STRING}.typelib)
-set(VAPI_FILE gtkmusic-${VERSION_STRING}.vapi)
+set(GIR_FILE GtkMusic-${VERSION}.gir)
+set(TYPELIB_FILE GtkMusic-${VERSION}.typelib)
+set(VAPI_FILE gtkmusic-${VERSION}.vapi)
 
 # =============================================================================
 # Dependencies
@@ -43,6 +44,10 @@ find_package(Vala REQUIRED)
 pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
 pkg_check_modules(GEE REQUIRED gee-0.8)
 
+if(${VALA_VERSION} VERSION_LESS "0.30")
+message(ERROR "This project requires Vala 0.30 or newer!")
+endif(${VALA_VERSION} VERSION_LESS "0.30")
+
 # =============================================================================
 # Main Library, Header and Pkg-Config
 # =============================================================================
@@ -56,10 +61,11 @@ vala_precompile(
              posix
 
     OPTIONS    -h gtkmusic-internals.h 
-               --internal-vapi gtkmusic-internals-${VERSION_STRING}.vapi 
-               --library gtkmusic-${VERSION_STRING} --gir ${GIR_FILE}
+               --internal-vapi gtkmusic-internals-${VERSION}.vapi
+            --shared-library libgtkmusic.so.${SOVERSION}
+               --library gtkmusic-${VERSION} --gir ${GIR_FILE}
 
-    GENERATE_VAPI gtkmusic-${VERSION_STRING}
+    GENERATE_VAPI gtkmusic-${VERSION}
     GENERATE_HEADER gtkmusic
 )
 
@@ -71,7 +77,8 @@ set(DEPS_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS} ${GEE_INCLUDE_DIRS})
 set(DEPS_CFLAGS_OTHER ${GTK3_CFLAGS_OTHER} ${GEE_CFLAGS_OTHER})
 
 add_library(gtkmusic SHARED ${VALA_C_LIBGTKMUSIC})
-set_target_properties(gtkmusic PROPERTIES SOVERSION ${VERSION_STRING})
+set_target_properties(gtkmusic PROPERTIES SOVERSION ${SOVERSION})
+set_target_properties(gtkmusic PROPERTIES VERSION ${VERSION})
 target_link_libraries(gtkmusic ${DEPS_LIBRARIES})
 target_include_directories(gtkmusic PUBLIC ${DEPS_INCLUDE_DIRS})
 target_compile_options(gtkmusic PUBLIC ${DEPS_CFLAGS_OTHER})
@@ -90,7 +97,7 @@ install(TARGETS gtkmusic gtkmusic_static
                             WORLD_READ WORLD_EXECUTE
         ARCHIVE DESTINATION lib/static)
 install(FILES ${CMAKE_BINARY_DIR}/gtkmusic.h
-        DESTINATION include/gtkmusic-${VERSION_STRING})
+        DESTINATION include/gtkmusic-${VERSION})
 
 
 # =============================================================================
@@ -107,7 +114,6 @@ if(INTROSPECTION_FOUND)
         TARGET gtkmusic
         POST_BUILD
         COMMAND ${INTROSPECTION_COMPILER} 
-                --shared-library=libgtkmusic-${VERSION_STRING} 
                 -o ${TYPELIB_FILE} ${GIR_FILE}
         COMMENT "Creating GObject Introspection files"
     )
diff --git a/INSTALL b/INSTALL
index 30106c3..b094e8b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,15 @@
 Suggested installation method
 
+Dependencies (Ubuntu package names):
+       libgee-0.8-dev
+       libgee-0.8-2
+       valac-0.30 (or newer)
+
+Optional Features
+       gobject-introspection
+       libgirepository
+       libgladeui-dev
+
 Assuming that cmake and all dependencies are installed, run:
        mkdir build
        cd build
diff --git a/gtkmusic.pc.in b/gtkmusic.pc.in
index 5fe3aab..b7b7c5a 100644
--- a/gtkmusic.pc.in
+++ b/gtkmusic.pc.in
@@ -9,5 +9,5 @@ Name: libgtkmusic
 Description: Gtk musical widgets collection
 Version: @VERSION_STRING@
 Requires: glib-2.0 gobject-2.0 gtk+-3.0 gee-0.8
-Libs: -L${libdir} -lgtkmusic-@VERSION_STRING@
+Libs: -L${libdir} -lgtkmusic
 Cflags: -I${includedir}/gtkmusic-@VERSION_STRING@
diff --git a/src/GuitarWidget.vala b/src/GuitarWidget.vala
index bcaf574..0eb91da 100644
--- a/src/GuitarWidget.vala
+++ b/src/GuitarWidget.vala
@@ -69,9 +69,9 @@ public class Guitar : DrawingArea {
     //=========================================================================
     //Signals
     //=========================================================================
-    public signal void note_pressed (Widget widget, Gdk.EventButton event,
+    public signal void note_pressed (Gdk.EventButton event,
                                      GuitarPosition pos);
-    public signal void note_released (Widget widget, Gdk.EventButton event,
+    public signal void note_released (Gdk.EventButton event,
                                       GuitarPosition pos);
     
     //=========================================================================
@@ -355,7 +355,7 @@ public class Guitar : DrawingArea {
     public override bool button_press_event (Gdk.EventButton event) {
         GuitarPosition? pos = point_to_position(event.x, event.y);
         if(pos != null)
-            note_pressed(this, event, pos);
+            note_pressed(event, pos);
         return true;
     }
 
@@ -368,7 +368,7 @@ public class Guitar : DrawingArea {
     public override bool button_release_event (Gdk.EventButton event) {
         GuitarPosition? pos = point_to_position(event.x, event.y);
         if(pos != null)
-            note_released(this, event, pos);
+            note_released(event, pos);
         return true;   
     }
 
diff --git a/src/PianoWidget.vala b/src/PianoWidget.vala
index 5a605f1..ea75562 100644
--- a/src/PianoWidget.vala
+++ b/src/PianoWidget.vala
@@ -47,9 +47,9 @@ public class Piano : DrawingArea {
     //Signals
     //=========================================================================
     
-    public signal void note_pressed (Widget widget, Gdk.EventButton event,
+    public signal void note_pressed (Gdk.EventButton event,
                                      int midi_note); //ushort not supported
-    public signal void note_released (Widget widget, Gdk.EventButton event,
+    public signal void note_released (Gdk.EventButton event,
                                       int midi_note); //ushort not supported
   
     //=========================================================================
@@ -302,12 +302,12 @@ public class Piano : DrawingArea {
     //====Events===============================================================
     
     public override bool button_press_event (Gdk.EventButton event) {
-        note_pressed(this, event, point_to_midi(event.x, event.y));
+        note_pressed(event, point_to_midi(event.x, event.y));
         return true;
     }
     
     public override bool button_release_event (Gdk.EventButton event) {
-        note_released(this, event, point_to_midi(event.x, event.y));
+        note_released(event, point_to_midi(event.x, event.y));
         return true;
     }
     
diff --git a/test/TestsGuitar.vala b/test/TestsGuitar.vala
index 41d6fae..40b4014 100644
--- a/test/TestsGuitar.vala
+++ b/test/TestsGuitar.vala
@@ -1,9 +1,8 @@
 using Gtk;
 using GtkMusic;
 
-void note_pressed_callback(Widget widget, Gdk.EventButton event, 
+void note_pressed_callback(Guitar guitar, Gdk.EventButton event, 
                            GuitarPosition pos) {
-    var guitar = widget as Guitar;
     stdout.printf("You clicked a %s!\n", guitar.position_to_note(pos));
     stdout.flush();
     if(event.button == 1) //left-click
diff --git a/test/TestsPiano.vala b/test/TestsPiano.vala
index 7fbb743..5e3b33d 100644
--- a/test/TestsPiano.vala
+++ b/test/TestsPiano.vala
@@ -1,8 +1,7 @@
 using Gtk;
 using GtkMusic;
 
-void note_pressed_callback(Widget widget, Gdk.EventButton event, int key) {
-    var piano = widget as Piano;
+void note_pressed_callback(Piano piano, Gdk.EventButton event, int key) {
     stdout.printf("You clicked key %d  \n", key); stdout.flush();
     if(event.button == 1)
         piano.mark_midi((ushort) key);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]