[longomatch] Use extension methods for the gtk bindings
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Use extension methods for the gtk bindings
- Date: Fri, 17 Apr 2015 16:20:34 +0000 (UTC)
commit 6534291e2c326e9cc3993c1b4247772d88418350
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Apr 9 18:00:21 2015 +0200
Use extension methods for the gtk bindings
LongoMatch.GUI.Helpers/GtkGlue.cs | 8 ++++----
LongoMatch.GUI.Multimedia/Gui/PlayerView.cs | 8 ++++----
LongoMatch.GUI/Gui/Dialog/CodecsChoiceDialog.cs | 2 +-
LongoMatch.GUI/Gui/Menu/PlaysMenu.cs | 10 +++++-----
4 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/LongoMatch.GUI.Helpers/GtkGlue.cs b/LongoMatch.GUI.Helpers/GtkGlue.cs
index 8051c66..bd426f8 100644
--- a/LongoMatch.GUI.Helpers/GtkGlue.cs
+++ b/LongoMatch.GUI.Helpers/GtkGlue.cs
@@ -22,7 +22,7 @@ using System.Runtime.InteropServices;
namespace LongoMatch
{
- public class GtkGlue
+ public static class GtkGlue
{
[DllImport ("libgtk-2.0.dll") /* willfully unmapped */]
@@ -31,13 +31,13 @@ namespace LongoMatch
[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)
+ public static void SetLabel (this MenuItem menu, string label)
{
gtk_menu_item_set_label (menu.Handle, GLib.Marshaller.StringToFilenamePtr (label));
}
- public static void EventButtonSetButton (EventButton ev, uint button)
+ public static void SetButton (this EventButton ev, uint button)
{
lgm_gtk_glue_gdk_event_button_set_button (ev.Handle, button);
}
@@ -47,7 +47,7 @@ namespace LongoMatch
/// </summary>
/// <param name="label">GtkLabel to set the handler for.</param>
/// <param name="urlHandler">URL handler.</param>
- public static void SetLinkHandler (Gtk.Label label, Action<string> urlHandler)
+ public static void SetLinkHandler (this Label label, Action<string> urlHandler)
{
new UrlHandlerClosure (urlHandler).ConnectTo (label);
}
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs
index b87a71b..78d191f 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerView.cs
@@ -373,9 +373,9 @@ namespace LongoMatch.Gui
void HandleTimescaleButtonPress (object o, Gtk.ButtonPressEventArgs args)
{
if (args.Event.Button == 1) {
- GtkGlue.EventButtonSetButton (args.Event, 2);
+ args.Event.SetButton (2);
} else {
- GtkGlue.EventButtonSetButton (args.Event, 1);
+ args.Event.SetButton (1);
}
if (!seeking) {
@@ -390,9 +390,9 @@ namespace LongoMatch.Gui
void HandleTimescaleButtonRelease (object o, Gtk.ButtonReleaseEventArgs args)
{
if (args.Event.Button == 1) {
- GtkGlue.EventButtonSetButton (args.Event, 2);
+ args.Event.SetButton (2);
} else {
- GtkGlue.EventButtonSetButton (args.Event, 1);
+ args.Event.SetButton (1);
}
if (seeking) {
diff --git a/LongoMatch.GUI/Gui/Dialog/CodecsChoiceDialog.cs b/LongoMatch.GUI/Gui/Dialog/CodecsChoiceDialog.cs
index 0c2bb4e..1407775 100644
--- a/LongoMatch.GUI/Gui/Dialog/CodecsChoiceDialog.cs
+++ b/LongoMatch.GUI/Gui/Dialog/CodecsChoiceDialog.cs
@@ -37,7 +37,7 @@ namespace LongoMatch.Gui.Dialog
titlelabel.ModifyFont (FontDescription.FromString (Config.Style.Font + " 14"));
// Configure URL handler for the links
- GtkGlue.SetLinkHandler (label1, (url) => {
+ label1.SetLinkHandler (url => {
try {
System.Diagnostics.Process.Start (url);
} catch {
diff --git a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
index 0492833..0ee58ac 100644
--- a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
+++ b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
@@ -71,7 +71,7 @@ namespace LongoMatch.Gui.Menus
if (eventType != null) {
string label = String.Format ("{0} in {1}", Catalog.GetString ("Add new
event"), eventType.Name);
- GtkGlue.MenuItemSetLabel (newPlay, label);
+ newPlay.SetLabel (label);
newPlay.Visible = true;
} else {
newPlay.Visible = false;
@@ -102,13 +102,13 @@ namespace LongoMatch.Gui.Menus
if (plays.Count > 0) {
string label = String.Format ("{0} ({1})", Catalog.GetString ("Delete"),
plays.Count);
- GtkGlue.MenuItemSetLabel (del, label);
+ del.SetLabel (label);
label = String.Format ("{0} ({1})", Catalog.GetString ("Add to playlist"),
plays.Count);
- GtkGlue.MenuItemSetLabel (addPLN, label);
+ addPLN.SetLabel (label);
label = String.Format ("{0} ({1})", Catalog.GetString ("Export to video
file"), plays.Count);
- GtkGlue.MenuItemSetLabel (render, label);
+ render.SetLabel (label);
label = String.Format ("{0} ({1})", Catalog.GetString ("Duplicate "),
plays.Count);
- GtkGlue.MenuItemSetLabel (duplicate, label);
+ duplicate.SetLabel (label);
}
if (moveCat.Visible) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]