tasque r89 - in trunk: . src
- From: bgmerrell svn gnome org
- To: svn-commits-list gnome org
- Subject: tasque r89 - in trunk: . src
- Date: Mon, 28 Jul 2008 17:05:03 +0000 (UTC)
Author: bgmerrell
Date: Mon Jul 28 17:05:03 2008
New Revision: 89
URL: http://svn.gnome.org/viewvc/tasque?rev=89&view=rev
Log:
* src/NoteDialog.cs: Scroll to bottom of window when a new note is created.
Cancel *new* note creation on Esc.
* src/NoteWidget.cs: Disallow saving empty notes. Expose public method to
focus on TextView widget.
Modified:
trunk/ChangeLog
trunk/src/NoteDialog.cs
trunk/src/NoteWidget.cs
Modified: trunk/src/NoteDialog.cs
==============================================================================
--- trunk/src/NoteDialog.cs (original)
+++ trunk/src/NoteDialog.cs Mon Jul 28 17:05:03 2008
@@ -12,6 +12,8 @@
private ITask task;
Gtk.VBox targetVBox;
+ Gtk.Button addButton = new Gtk.Button(Gtk.Stock.Add);
+ Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow ();
#region Constructors
public NoteDialog (Gtk.Window parentWindow, ITask task)
@@ -21,11 +23,11 @@
this.task = task;
this.Title = String.Format(Catalog.GetString("Notes for: {0:s}"), task.Name);
this.HasSeparator = false;
- this.SetSizeRequest(350,320);
+ this.SetSizeRequest(500,320);
this.Icon = Utilities.GetIcon ("tasque-16", 16);
//this.Flags = Gtk.DialogFlags.DestroyWithParent;
- Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow ();
+
sw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
sw.HscrollbarPolicy = Gtk.PolicyType.Never;
@@ -51,6 +53,7 @@
NoteWidget noteWidget = new NoteWidget (note);
noteWidget.TextChanged += OnNoteTextChanged;
noteWidget.DeleteButtonClicked += OnDeleteButtonClicked;
+ noteWidget.EditCanceled += OnEditCanceled;
noteWidget.Show ();
targetVBox.PackStart (noteWidget, false, false, 0);
}
@@ -62,10 +65,10 @@
VBox.PackStart (sw, true, true, 0);
if(task.SupportsMultipleNotes) {
- Gtk.Button button = new Gtk.Button(Gtk.Stock.Add);
- button.Show();
- this.ActionArea.PackStart(button);
- button.Clicked += OnAddButtonClicked;
+ addButton = new Gtk.Button(Gtk.Stock.Add);
+ addButton.Show();
+ this.ActionArea.PackStart(addButton);
+ addButton.Clicked += OnAddButtonClicked;
}
AddButton (Gtk.Stock.Close, Gtk.ResponseType.Close);
@@ -92,8 +95,11 @@
NoteWidget noteWidget = new NoteWidget (null);
noteWidget.TextChanged += OnNoteTextChanged;
noteWidget.DeleteButtonClicked += OnDeleteButtonClicked;
- noteWidget.Show ();
+ noteWidget.EditCanceled += OnEditCanceled;
targetVBox.PackStart (noteWidget, false, false, 0);
+ noteWidget.FocusTextArea ();
+ noteWidget.SaveButton.Sensitive = false;
+ noteWidget.Show ();
}
#endregion // Public Methods
@@ -103,10 +109,12 @@
#region Event Handlers
void OnAddButtonClicked (object sender, EventArgs args)
{
- Logger.Debug("Add button clicked in dialog");
this.CreateNewNote();
- }
+ // scrolling to the bottom should work fine to make the
+ // new note visible to the user
+ sw.Vadjustment.Value = sw.Vadjustment.Upper;
+ }
void OnDeleteButtonClicked (object sender, EventArgs args)
{
@@ -119,7 +127,15 @@
Logger.Debug(e.ToString());
}
}
-
+
+ void OnEditCanceled (object sender, EventArgs args)
+ {
+ NoteWidget nWidget = sender as NoteWidget;
+ // remove the note widget if it's empty
+ if (nWidget.Text == String.Empty)
+ targetVBox.Remove (nWidget);
+ }
+
void OnNoteTextChanged (object sender, EventArgs args)
{
NoteWidget nWidget = sender as NoteWidget;
Modified: trunk/src/NoteWidget.cs
==============================================================================
--- trunk/src/NoteWidget.cs (original)
+++ trunk/src/NoteWidget.cs Mon Jul 28 17:05:03 2008
@@ -3,6 +3,7 @@
using System;
using Mono.Unix;
+using Gtk;
namespace Tasque
{
@@ -34,11 +35,12 @@
#region Constructors
public NoteWidget (INote note)
{
+ this.KeyPressEvent += OnNoteWidgetKeyPressed;
this.note = note;
this.text = ( (note == null) || (note.Text == null) ) ? string.Empty : note.Text.Trim ();
this.ShowTabs = false;
-
+
viewPage = MakeViewPage ();
editPage = MakeEditPage ();
@@ -57,12 +59,16 @@
// Go to view mode (switch to the view page)
ShowPage (viewPageId);
}
+ this.textView.Buffer.Changed += OnTextViewChanged;
+
}
#endregion // Constructors
#region Events
public event EventHandler TextChanged;
public event EventHandler DeleteButtonClicked;
+ public event EventHandler EditCanceled;
+ public event EventHandler EditButtonClicked;
#endregion // Events
#region Properties
@@ -90,9 +96,18 @@
}
}
}
+
+ public Gtk.Button SaveButton
+ {
+ get { return saveButton; }
+ }
#endregion // Properties
#region Public Methods
+ public void FocusTextArea()
+ {
+ textView.GrabFocus();
+ }
#endregion // Public Methods
#region Private Methods
@@ -154,7 +169,7 @@
hButtonBox.Layout = Gtk.ButtonBoxStyle.End;
cancelButton = new Gtk.Button (Gtk.Stock.Cancel);
- cancelButton.Clicked += OnCancelButtonClicked;
+ cancelButton.Clicked += OnEditCanceled;
cancelButton.NoShowAll = true;
hButtonBox.PackStart (cancelButton, false, false, 0);
@@ -257,11 +272,22 @@
private void OnEditButtonClicked (object sender, EventArgs args)
{
ShowPage (editPageId);
+ FocusTextArea();
}
- private void OnCancelButtonClicked (object sender, EventArgs args)
+ void OnEditCanceled (object sender, EventArgs args)
{
+ // go back to the view page
ShowPage (viewPageId);
+
+ // Let the event handlers know cancel was pushed
+ if (this.EditCanceled == null)
+ return;
+ try {
+ EditCanceled (this, EventArgs.Empty);
+ } catch (Exception e) {
+ Logger.Warn ("Exception in NoteWidget.DeleteButtonClicked handler: {0}", e.Message);
+ }
}
private void OnSaveButtonClicked (object sender, EventArgs args)
@@ -283,6 +309,29 @@
}
}
}
+
+ void OnTextViewChanged (object sender, EventArgs args)
+ {
+ if (this.textView.Buffer.Text == null || this.textView.Buffer.Text.Trim() == String.Empty)
+ this.saveButton.Sensitive = false;
+ else
+ this.saveButton.Sensitive = true;
+ }
+
+ private void OnNoteWidgetKeyPressed(object o, KeyPressEventArgs args)
+ {
+ switch (args.Event.Key) {
+ case Gdk.Key.Escape:
+ // fire the cancel event if the note is
+ // in edit mode.
+ if (Page == editPageId) {
+ OnEditCanceled(this, EventArgs.Empty);
+ }
+ break;
+ default:
+ break;
+ }
+ }
#endregion // Event Handlers
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]