[gnome-subtitles] Fixed handling of the delete event in dialogs
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-subtitles] Fixed handling of the delete event in dialogs
- Date: Sun, 31 May 2009 14:06:25 -0400 (EDT)
commit 4016beef7c1f1cdfbf431a3b1281453d7994943e
Author: Pedro Castro <mail pedrocastro org>
Date: Sun May 31 17:04:24 2009 +0100
Fixed handling of the delete event in dialogs
---
src/GnomeSubtitles/Dialog/BaseDialog.cs | 19 +++++++++++++++++++
src/GnomeSubtitles/Dialog/Dialogs.cs | 10 +++++++---
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/GnomeSubtitles/Dialog/BaseDialog.cs b/src/GnomeSubtitles/Dialog/BaseDialog.cs
index 805e853..b937b75 100644
--- a/src/GnomeSubtitles/Dialog/BaseDialog.cs
+++ b/src/GnomeSubtitles/Dialog/BaseDialog.cs
@@ -18,6 +18,7 @@
*/
using Gtk;
+using System;
namespace GnomeSubtitles.Dialog {
@@ -29,6 +30,11 @@ public abstract class BaseDialog {
public BaseDialog () {
}
+ /* Events */
+
+ public event EventHandler Destroyed;
+
+
/* Properties */
public virtual DialogScope Scope {
@@ -57,6 +63,7 @@ public abstract class BaseDialog {
public virtual void Destroy () {
dialog.Destroy();
+ EmitDestroyedEvent();
}
@@ -77,7 +84,9 @@ public abstract class BaseDialog {
protected void Init (Gtk.Dialog dialog) {
this.dialog = dialog;
Util.SetBaseWindowFromUi(dialog);
+
dialog.Response += OnResponse;
+ dialog.DeleteEvent += OnDeleteEvent;
}
protected Gtk.Dialog GetDialog () {
@@ -104,6 +113,16 @@ public abstract class BaseDialog {
}
}
+ private void OnDeleteEvent (object o, DeleteEventArgs args) {
+ args.RetVal = true;
+ }
+
+ private void EmitDestroyedEvent () {
+ if (Destroyed != null) {
+ Destroyed(this, EventArgs.Empty);
+ }
+ }
+
}
diff --git a/src/GnomeSubtitles/Dialog/Dialogs.cs b/src/GnomeSubtitles/Dialog/Dialogs.cs
index 5c3f02d..98b0711 100644
--- a/src/GnomeSubtitles/Dialog/Dialogs.cs
+++ b/src/GnomeSubtitles/Dialog/Dialogs.cs
@@ -40,8 +40,10 @@ public class Dialogs {
return null;
dialog = newDialog as BaseDialog;
- if (dialog.Scope != DialogScope.Singleton)
+ if (dialog.Scope != DialogScope.Singleton) {
dialogs[dialogType] = dialog;
+ dialog.Destroyed += OnDialogDestroyed;
+ }
}
return dialog;
}
@@ -62,7 +64,6 @@ public class Dialogs {
BaseDialog dialog = dialogs[type] as BaseDialog;
if ((dialog.Scope == DialogScope.Singleton) || (dialog.Scope == DialogScope.Document)) {
dialog.Destroy();
- dialogs.Remove(type);
}
}
}
@@ -76,11 +77,14 @@ public class Dialogs {
BaseDialog dialog = dialogs[type] as BaseDialog;
if (dialog.Scope == DialogScope.Video) {
dialog.Destroy();
- dialogs.Remove(type);
}
}
}
+ private void OnDialogDestroyed (object o, EventArgs args) {
+ dialogs.Remove(o.GetType());
+ }
+
}
}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]