[longomatch] Factorize window creation and make shortcut work everywhere
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Factorize window creation and make shortcut work everywhere
- Date: Wed, 4 Feb 2015 11:03:32 +0000 (UTC)
commit f1c20aba0b23e9c80d0b804e65bdcc662cf6bebb
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Feb 4 11:53:53 2015 +0100
Factorize window creation and make shortcut work everywhere
LongoMatch.GUI.Helpers/ExternalWindow.cs | 54 ++++++++++++++++++++
.../LongoMatch.GUI.Helpers.csproj | 1 +
LongoMatch.GUI.Helpers/Makefile.am | 5 +-
LongoMatch.GUI/Gui/Component/AnalysisComponent.cs | 19 ++-----
LongoMatch.GUI/Gui/Component/CodingWidget.cs | 10 +++-
5 files changed, 70 insertions(+), 19 deletions(-)
---
diff --git a/LongoMatch.GUI.Helpers/ExternalWindow.cs b/LongoMatch.GUI.Helpers/ExternalWindow.cs
new file mode 100644
index 0000000..94de3f2
--- /dev/null
+++ b/LongoMatch.GUI.Helpers/ExternalWindow.cs
@@ -0,0 +1,54 @@
+//
+// Copyright (C) 2015 Andoni Morales Alastruey
+//
+// 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.
+//
+using System;
+using Gtk;
+using LongoMatch.Core.Common;
+
+namespace LongoMatch.GUI.Helpers
+{
+ public class ExternalWindow: Window
+ {
+ EventBox box;
+
+ public ExternalWindow (): base (WindowType.Toplevel)
+ {
+ Icon = LongoMatch.Gui.Helpers.Misc.LoadIcon ("longomatch", IconSize.Menu);
+
+ box = new EventBox ();
+ box.Name = "lightbackgroundeventbox";
+ box.KeyPressEvent += (o, args) => {
+ Config.EventsBroker.EmitKeyPressed (this, Keyboard.ParseEvent (args.Event));
+ };
+ base.Add (box);
+ box.CanFocus = true;
+ Focus = box;
+ box.Show ();
+ }
+
+ public Widget Box {
+ get {
+ return box;
+ }
+ }
+
+ new public void Add (Widget widget) {
+ box.Add (widget);
+ }
+ }
+}
+
diff --git a/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj
b/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj
index dd2fb53..eaa486f 100644
--- a/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj
+++ b/LongoMatch.GUI.Helpers/LongoMatch.GUI.Helpers.csproj
@@ -36,6 +36,7 @@
<Compile Include="MessagesHelpers.cs" />
<Compile Include="Misc.cs" />
<Compile Include="GtkGlue.cs" />
+ <Compile Include="ExternalWindow.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
diff --git a/LongoMatch.GUI.Helpers/Makefile.am b/LongoMatch.GUI.Helpers/Makefile.am
index 9c39012..0d54ee3 100644
--- a/LongoMatch.GUI.Helpers/Makefile.am
+++ b/LongoMatch.GUI.Helpers/Makefile.am
@@ -4,9 +4,10 @@ TARGET = library
LINK = $(REF_DEP_LONGOMATCH_GUI_HELPERS)
-SOURCES = FileChooserHelper.cs \
- MessagesHelpers.cs \
+SOURCES = ExternalWindow.cs \
+ FileChooserHelper.cs \
GtkGlue.cs \
+ MessagesHelpers.cs \
Misc.cs
RESOURCES =
diff --git a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
index c301a36..11982da 100644
--- a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
@@ -20,6 +20,7 @@ using Gtk;
using LongoMatch.Core.Common;
using LongoMatch.Core.Interfaces.GUI;
using LongoMatch.Core.Store;
+using LongoMatch.GUI.Helpers;
namespace LongoMatch.Gui.Component
{
@@ -127,27 +128,17 @@ namespace LongoMatch.Gui.Component
* are beeing changed */
playercapturer.Pause ();
if (!detachedPlayer) {
- EventBox box;
Log.Debug ("Detaching player");
- playerWindow = new Gtk.Window (Constants.SOFTWARE_NAME);
+ ExternalWindow playerWindow = new ExternalWindow ();
+ this.playerWindow = playerWindow;
+ playerWindow.Title = Constants.SOFTWARE_NAME;
int player_width = playercapturer.Allocation.Width;
int player_height = playercapturer.Allocation.Height;
playerWindow.SetDefaultSize (player_width, player_height);
- playerWindow.Icon = Stetic.IconLoader.LoadIcon (this, "longomatch",
IconSize.Button);
playerWindow.DeleteEvent += (o, args) => DetachPlayer ();
- box = new EventBox ();
- box.Name = "lightbackgroundeventbox";
- box.KeyPressEvent += (o, args) => {
- Config.EventsBroker.EmitKeyPressed (this, Keyboard.ParseEvent
(args.Event));
- };
- playerWindow.Add (box);
-
- box.Show ();
- box.CanFocus = true;
playerWindow.Show ();
- playercapturer.Reparent (box);
- playerWindow.Focus = box;
+ playercapturer.Reparent (playerWindow.Box);
// Hack to reposition video window in widget for OSX
playerWindow.Resize (player_width + 10, player_height);
videowidgetsbox.Visible = false;
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index 967ec90..d31f62f 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -25,6 +25,7 @@ using LongoMatch.Core.Store.Templates;
using LongoMatch.Drawing.Cairo;
using LongoMatch.Drawing.Widgets;
using Mono.Unix;
+using LongoMatch.GUI.Helpers;
namespace LongoMatch.Gui.Component
{
@@ -258,10 +259,11 @@ namespace LongoMatch.Gui.Component
Notebook CreateNewWindow (Notebook source, Widget page, int x, int y)
{
- Window window;
+ ExternalWindow window;
+ EventBox box;
Notebook notebook;
- window = new Window (WindowType.Toplevel);
+ window = new ExternalWindow ();
if (page == timeline) {
window.Title = Catalog.GetString ("Timeline");
} else if (page == dashboardhpaned) {
@@ -269,10 +271,12 @@ namespace LongoMatch.Gui.Component
} else if (page == playspositionviewer1) {
window.Title = Catalog.GetString ("Zonal tags viewer");
}
- window.Icon = Stetic.IconLoader.LoadIcon (this, "longomatch", IconSize.Menu);
+
notebook = new Notebook ();
notebook.ShowTabs = false;
+ notebook.CanFocus = false;
//notebook.Group = source.Group;
+
window.Add (notebook);
window.SetDefaultSize (page.Allocation.Width, page.Allocation.Height);
window.Move (x, y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]