[longomatch] Make the seek bar jump to the clicked position



commit 44d337c15709e10ca14303aeecf8d55633c28f35
Author: Jorge Zapata <jorgeluis zapata gmail com>
Date:   Wed Dec 17 13:27:18 2014 +0100

    Make the seek bar jump to the clicked position
    
    For that we need to add glue functions on libcesarplayer so the Gdk
    Event can be modified. The union GdkEvent is not mapped, every access
    is done through glue functions on gtk-sharp, we need to do the same
    but for setting the button value.

 .../Gui => LongoMatch.GUI.Helpers}/GtkGlue.cs      |    8 ++++
 .../LongoMatch.GUI.Helpers.csproj                  |    4 ++
 .../LongoMatch.GUI.Helpers.dll.config              |    5 +++
 LongoMatch.GUI.Helpers/Makefile.am                 |    5 +++
 LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs         |   27 ++++++++++++++-
 LongoMatch.GUI.Multimedia/gtk-gui/objects.xml      |    1 -
 LongoMatch.GUI/LongoMatch.GUI.csproj               |    1 -
 LongoMatch.GUI/Makefile.am                         |    1 -
 libcesarplayer/Makefile.am                         |    2 +
 libcesarplayer/lgm-gtk-glue.c                      |   25 ++++++++++++++
 libcesarplayer/lgm-gtk-glue.h                      |   35 ++++++++++++++++++++
 libcesarplayer/liblongomatch.cproj                 |    2 +
 12 files changed, 112 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/GtkGlue.cs b/LongoMatch.GUI.Helpers/GtkGlue.cs
similarity index 88%
rename from LongoMatch.GUI/Gui/GtkGlue.cs
rename to LongoMatch.GUI.Helpers/GtkGlue.cs
index 56fed75..f0ad5f6 100644
--- a/LongoMatch.GUI/Gui/GtkGlue.cs
+++ b/LongoMatch.GUI.Helpers/GtkGlue.cs
@@ -17,6 +17,7 @@
 //
 using System;
 using Gtk;
+using Gdk;
 using System.Runtime.InteropServices;
 
 namespace LongoMatch
@@ -26,11 +27,18 @@ namespace LongoMatch
                
                [DllImport("libgtk-2.0.dll") /* willfully unmapped */ ]
                static extern void gtk_menu_item_set_label (IntPtr menu, IntPtr label);
+               [DllImport ("libcesarplayer.dll")]
+               static extern void lgm_gtk_glue_gdk_event_button_set_button (IntPtr evt, uint button);
                
                public static void MenuItemSetLabel (MenuItem menu, string label) {
                        gtk_menu_item_set_label (menu.Handle, GLib.Marshaller.StringToFilenamePtr (label));
                }
 
+
+               public static void EventButtonSetButton (EventButton ev, uint button) {
+                       lgm_gtk_glue_gdk_event_button_set_button (ev.Handle, button);
+               }
+
                /// <summary>
                /// Sets the link handler for a given GtkLabel.
                /// </summary>
diff --git a/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj 
b/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj
index 13c1284..7c8cfc3 100644
--- a/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj
+++ b/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj
@@ -30,6 +30,7 @@
     <Compile Include="FileChooserHelper.cs" />
     <Compile Include="MessagesHelpers.cs" />
     <Compile Include="Misc.cs" />
+    <Compile Include="GtkGlue.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
@@ -54,4 +55,7 @@
     </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ItemGroup>
+    <None Include="LongoMatch.GUI.Helpers.dll.config" />
+  </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.dll.config 
b/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.dll.config
new file mode 100644
index 0000000..353c045
--- /dev/null
+++ b/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.dll.config
@@ -0,0 +1,5 @@
+<configuration>
+        <dllmap dll="libcesarplayer.dll" target="libcesarplayer.dylib"/>
+        <dllmap os="linux" dll="libcesarplayer.dll" target="libcesarplayer.so"/>
+        <dllmap os="windows" dll="libgtk-2.0.dll" target="libcesarplayer.dll"/>
+</configuration>
\ No newline at end of file
diff --git a/LongoMatch.GUI.Helpers/Makefile.am b/LongoMatch.GUI.Helpers/Makefile.am
index a846581..9c39012 100644
--- a/LongoMatch.GUI.Helpers/Makefile.am
+++ b/LongoMatch.GUI.Helpers/Makefile.am
@@ -6,8 +6,13 @@ LINK = $(REF_DEP_LONGOMATCH_GUI_HELPERS)
 
 SOURCES = FileChooserHelper.cs \
        MessagesHelpers.cs \
+       GtkGlue.cs \
        Misc.cs
 
 RESOURCES = 
 
+DLLCONFIG = LongoMatch.GUI.Helpers.dll.config
+
 include $(top_srcdir)/build/build.mk
+
+EXTRA_DIST += LongoMatch.GUI.Helpers.dll.config
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index c1cce16..ad9c30c 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -34,6 +34,7 @@ using LongoMatch.Drawing.Widgets;
 using LongoMatch.Multimedia.Utils;
 using LongoMatch.Video.Common;
 using LongoMatch.Video.Utils;
+using LongoMatch.Gui.Helpers;
 using Image = LongoMatch.Core.Common.Image;
 using System.Collections.Generic;
 
@@ -493,7 +494,9 @@ namespace LongoMatch.Gui
                        drawbutton.Clicked += OnDrawButtonClicked;
                        volumebutton.Clicked += OnVolumebuttonClicked;
                        timescale.ValueChanged += OnTimescaleValueChanged;
-                       timescale.AdjustBounds += OnTimescaleAdjustBounds;                      
+                       timescale.AdjustBounds += OnTimescaleAdjustBounds;
+                       timescale.ButtonPressEvent += OnTimescaleButtonPress;
+                       timescale.ButtonReleaseEvent += OnTimescaleButtonRelease;
                        vscale1.FormatValue += OnVscale1FormatValue;
                        vscale1.ValueChanged += OnVscale1ValueChanged;
 
@@ -764,6 +767,28 @@ namespace LongoMatch.Gui
                        return true;
                }
 
+               [GLib.ConnectBefore]
+               void OnTimescaleButtonPress (object o, Gtk.ButtonPressEventArgs args)
+               {
+                       if (args.Event.Button == 1)
+                       {
+                               GtkGlue.EventButtonSetButton(args.Event, 2);
+                       } else {
+                               GtkGlue.EventButtonSetButton(args.Event, 1);
+                       }
+               }
+
+               [GLib.ConnectBefore]
+               void OnTimescaleButtonRelease (object o, Gtk.ButtonReleaseEventArgs args)
+               {
+                       if (args.Event.Button == 1)
+                       {
+                               GtkGlue.EventButtonSetButton(args.Event, 2);
+                       } else {
+                               GtkGlue.EventButtonSetButton(args.Event, 1);
+                       }
+               }
+
                void OnTimescaleAdjustBounds (object o, Gtk.AdjustBoundsArgs args)
                {
                        double pos;
diff --git a/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml b/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml
index ff002a4..354c89c 100644
--- a/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml
+++ b/LongoMatch.GUI.Multimedia/gtk-gui/objects.xml
@@ -12,7 +12,6 @@
       <itemgroup label="IPlayerBin Properties">
         <property name="Sensitive" />
         <property name="CloseAlwaysVisible" />
-        <property name="CloseAlwaysHidden" />
       </itemgroup>
     </itemgroups>
     <signals>
diff --git a/LongoMatch.GUI/LongoMatch.GUI.csproj b/LongoMatch.GUI/LongoMatch.GUI.csproj
index 40b8c96..d70fef8 100644
--- a/LongoMatch.GUI/LongoMatch.GUI.csproj
+++ b/LongoMatch.GUI/LongoMatch.GUI.csproj
@@ -143,7 +143,6 @@
     <Compile Include="Gui\Component\PlaysPositionViewer.cs" />
     <Compile Include="gtk-gui\LongoMatch.Gui.Component.PlaysPositionViewer.cs" />
     <Compile Include="Gui\Menu\PlaysMenu.cs" />
-    <Compile Include="Gui\GtkGlue.cs" />
     <Compile Include="Gui\Component\TeamsComboBox.cs" />
     <Compile Include="Gui\Component\MediaFileChooser.cs" />
     <Compile Include="gtk-gui\LongoMatch.Gui.Component.MediaFileChooser.cs" />
diff --git a/LongoMatch.GUI/Makefile.am b/LongoMatch.GUI/Makefile.am
index aa65e2d..57dee8d 100644
--- a/LongoMatch.GUI/Makefile.am
+++ b/LongoMatch.GUI/Makefile.am
@@ -57,7 +57,6 @@ SOURCES = Gui/Cairo.cs \
        Gui/Dialog/VideoConversionTool.cs \
        Gui/Dialog/VideoEditionProperties.cs \
        Gui/GUIToolkit.cs \
-       Gui/GtkGlue.cs \
        Gui/MainWindow.cs \
        Gui/Menu/PeriodsMenu.cs \
        Gui/Menu/PlaysMenu.cs \
diff --git a/libcesarplayer/Makefile.am b/libcesarplayer/Makefile.am
index 02f9a2b..beb3d20 100644
--- a/libcesarplayer/Makefile.am
+++ b/libcesarplayer/Makefile.am
@@ -34,6 +34,8 @@ lib_LTLIBRARIES = \
 libcesarplayer_la_SOURCES = \
        $(BVWMARSHALFILES) \
        common.h\
+       lgm-gtk-glue.c\
+       lgm-gtk-glue.h\
        lgm-video-player.h\
        lgm-video-player.c\
        gstscreenshot.c \
diff --git a/libcesarplayer/lgm-gtk-glue.c b/libcesarplayer/lgm-gtk-glue.c
new file mode 100644
index 0000000..a8a2d56
--- /dev/null
+++ b/libcesarplayer/lgm-gtk-glue.c
@@ -0,0 +1,25 @@
+/* 
+ * Copyright (C) 2014  Andoni Morales Alastruey <ylatuya gmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+#include "lgm-gtk-glue.h"
+
+void lgm_gtk_glue_gdk_event_button_set_button (GdkEventButton *event, guint button)
+{
+  event->button = button;
+}
+
diff --git a/libcesarplayer/lgm-gtk-glue.h b/libcesarplayer/lgm-gtk-glue.h
new file mode 100644
index 0000000..7077a01
--- /dev/null
+++ b/libcesarplayer/lgm-gtk-glue.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2014 Andoni Morales <ylatuya gmail com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+ 
+#ifndef HAVE_LGM_GTK_GLUE_H
+#define HAVE_LGM_GTK_GLUE_H
+
+#ifdef WIN32
+#define EXPORT __declspec (dllexport)
+#else
+#define EXPORT
+#endif
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+EXPORT void lgm_gtk_glue_gdk_event_button_set_button (GdkEventButton *event, guint button);
+G_END_DECLS
+
+#endif
\ No newline at end of file
diff --git a/libcesarplayer/liblongomatch.cproj b/libcesarplayer/liblongomatch.cproj
index 16564d8..abbc56f 100644
--- a/libcesarplayer/liblongomatch.cproj
+++ b/libcesarplayer/liblongomatch.cproj
@@ -64,6 +64,7 @@
     <None Include="gst-video-encoder.h" />
     <None Include="lgm-video-player.h" />
     <None Include="gst-nle-source.h" />
+    <None Include="lgm-gtk-glue.h" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="gst-camera-capturer.c" />
@@ -77,5 +78,6 @@
     <Compile Include="gst-nle-source.c" />
     <Compile Include="lgm-video-player.c" />
     <Compile Include="video-utils.m" />
+    <Compile Include="lgm-gtk-glue.c" />
   </ItemGroup>
 </Project>
\ No newline at end of file


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