Skip to content

Commit 24c055c

Browse files
committed
Additions to the GUI and the editor
1 parent 93af66d commit 24c055c

File tree

3 files changed

+96
-39
lines changed

3 files changed

+96
-39
lines changed

moNotational Velocity/MainWindow.cs

+28-14
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public MainWindow () : base(Gtk.WindowType.Toplevel)
2626
noteslist.AppendColumn ("Title", new Gtk.CellRendererText (), "text", 0);
2727
noteslist.AppendColumn ("Date modified", new Gtk.CellRendererText (), "text", 1);
2828

29+
editor.WrapMode = WrapMode.Word;
30+
2931
this.notesDirPath = cfg.notesDirPath;
3032

3133
Console.WriteLine ("Using notes at " + notesDirPath);
@@ -117,6 +119,7 @@ protected virtual void onTextChange (object o, System.EventArgs args)
117119

118120
string text = buf.Text;
119121
notesStore.storeNoteContent (currentNote, text);
122+
120123
}
121124
}
122125

@@ -142,20 +145,24 @@ protected virtual void onSearchbarKeyEvent (object o, Gtk.KeyPressEventArgs args
142145
string key = args.Event.Key.ToString ();
143146
Console.WriteLine ("searchbar key: " + key);
144147

145-
if (key.Equals ("Return") && !notesStore.doesNoteExist (searchbar.Text.Trim ()) && searchbar.Text != null && searchbar.Text.Length > 0) {
146-
Note newNote = new Note (searchbar.Text.Trim (), "");
147-
store.AddNode (new NoteNode (newNote));
148-
currentNote = newNote.title;
149-
notesStore.createNote (currentNote);
150-
buf = editor.Buffer;
151-
buf.Text = "";
152-
editor.GrabFocus ();
153-
} else if (key.Equals ("Down") ){
154-
noteslist.GrabFocus();
148+
if (key.Equals ("Return")) {
155149

156-
NoteNode node = noteslist.NodeSelection.SelectedNode as NoteNode;
157-
158-
loadNoteToBuffer (node);
150+
if (!notesStore.doesNoteExist (searchbar.Text.Trim ()) && searchbar.Text != null && searchbar.Text.Length > 0) {
151+
Note newNote = new Note (searchbar.Text.Trim (), "");
152+
store.AddNode (new NoteNode (newNote));
153+
currentNote = newNote.title;
154+
notesStore.createNote (currentNote);
155+
buf = editor.Buffer;
156+
buf.Text = "";
157+
editor.GrabFocus ();
158+
}
159+
160+
} else if (key.Equals ("Down")) {
161+
noteslist.GrabFocus ();
162+
163+
NoteNode node = noteslist.NodeSelection.SelectedNode as NoteNode;
164+
165+
loadNoteToBuffer (node);
159166
}
160167

161168
}
@@ -178,8 +185,15 @@ private void loadNoteToBuffer (NoteNode node)
178185
if (node != null && !searchbar.HasFocus) {
179186
currentNote = node.Title;
180187
searchbar.Text = node.Title;
188+
loadNoteToBuffer (node.Title);
189+
}
190+
}
191+
192+
private void loadNoteToBuffer (String title)
193+
{
194+
if (title != null) {
181195
buf = editor.Buffer;
182-
buf.Text = notesStore.getNoteContent (node.Title);
196+
buf.Text = notesStore.getNoteContent (title);
183197
}
184198
}
185199

moNotational Velocity/gtk-gui/MainWindow.cs

+29-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public partial class MainWindow
77

88
private global::Gtk.Entry searchbar;
99

10+
private global::Gtk.VPaned vpaned1;
11+
1012
private global::Gtk.ScrolledWindow GtkScrolledWindow1;
1113

1214
private global::Gtk.NodeView noteslist;
@@ -15,14 +17,16 @@ public partial class MainWindow
1517

1618
private global::Gtk.TextView editor;
1719

20+
private global::Gtk.Statusbar statusbar;
21+
1822
protected virtual void Build ()
1923
{
2024
global::Stetic.Gui.Initialize (this);
2125
// Widget MainWindow
2226
this.Name = "MainWindow";
2327
this.Title = global::Mono.Unix.Catalog.GetString ("moNotational Velocity");
2428
this.Icon = global::Stetic.IconLoader.LoadIcon (this, "gtk-edit", global::Gtk.IconSize.Menu);
25-
this.WindowPosition = ((global::Gtk.WindowPosition)(4));
29+
this.WindowPosition = ((global::Gtk.WindowPosition)(3));
2630
this.Gravity = ((global::Gdk.Gravity)(5));
2731
// Container child MainWindow.Gtk.Container+ContainerChild
2832
this.vbox1 = new global::Gtk.VBox ();
@@ -40,6 +44,11 @@ protected virtual void Build ()
4044
w1.Expand = false;
4145
w1.Fill = false;
4246
// Container child vbox1.Gtk.Box+BoxChild
47+
this.vpaned1 = new global::Gtk.VPaned ();
48+
this.vpaned1.CanFocus = true;
49+
this.vpaned1.Name = "vpaned1";
50+
this.vpaned1.Position = 112;
51+
// Container child vpaned1.Gtk.Paned+PanedChild
4352
this.GtkScrolledWindow1 = new global::Gtk.ScrolledWindow ();
4453
this.GtkScrolledWindow1.Name = "GtkScrolledWindow1";
4554
this.GtkScrolledWindow1.ShadowType = ((global::Gtk.ShadowType)(1));
@@ -48,10 +57,10 @@ protected virtual void Build ()
4857
this.noteslist.CanFocus = true;
4958
this.noteslist.Name = "noteslist";
5059
this.GtkScrolledWindow1.Add (this.noteslist);
51-
this.vbox1.Add (this.GtkScrolledWindow1);
52-
global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkScrolledWindow1]));
53-
w3.Position = 1;
54-
// Container child vbox1.Gtk.Box+BoxChild
60+
this.vpaned1.Add (this.GtkScrolledWindow1);
61+
global::Gtk.Paned.PanedChild w3 = ((global::Gtk.Paned.PanedChild)(this.vpaned1[this.GtkScrolledWindow1]));
62+
w3.Resize = false;
63+
// Container child vpaned1.Gtk.Paned+PanedChild
5564
this.GtkScrolledWindow = new global::Gtk.ScrolledWindow ();
5665
this.GtkScrolledWindow.Name = "GtkScrolledWindow";
5766
this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
@@ -60,15 +69,25 @@ protected virtual void Build ()
6069
this.editor.CanFocus = true;
6170
this.editor.Name = "editor";
6271
this.GtkScrolledWindow.Add (this.editor);
63-
this.vbox1.Add (this.GtkScrolledWindow);
64-
global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.GtkScrolledWindow]));
65-
w5.Position = 2;
72+
this.vpaned1.Add (this.GtkScrolledWindow);
73+
this.vbox1.Add (this.vpaned1);
74+
global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.vpaned1]));
75+
w6.Position = 1;
76+
// Container child vbox1.Gtk.Box+BoxChild
77+
this.statusbar = new global::Gtk.Statusbar ();
78+
this.statusbar.Name = "statusbar";
79+
this.statusbar.Spacing = 6;
80+
this.vbox1.Add (this.statusbar);
81+
global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.statusbar]));
82+
w7.Position = 2;
83+
w7.Expand = false;
84+
w7.Fill = false;
6685
this.Add (this.vbox1);
6786
if ((this.Child != null)) {
6887
this.Child.ShowAll ();
6988
}
70-
this.DefaultWidth = 529;
71-
this.DefaultHeight = 342;
89+
this.DefaultWidth = 591;
90+
this.DefaultHeight = 415;
7291
this.Show ();
7392
this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent);
7493
}

moNotational Velocity/gtk-gui/gui.stetic

+39-15
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
99
<widget-library name="../bin/Debug/monovel.exe" internal="true" />
1010
</import>
11-
<widget class="Gtk.Window" id="MainWindow" design-size="529 342">
11+
<widget class="Gtk.Window" id="MainWindow" design-size="591 415">
1212
<property name="MemberName" />
1313
<property name="Title" translatable="yes">moNotational Velocity</property>
1414
<property name="Icon">stock:gtk-edit Menu</property>
15-
<property name="WindowPosition">CenterOnParent</property>
15+
<property name="WindowPosition">CenterAlways</property>
1616
<property name="Gravity">Center</property>
1717
<signal name="DeleteEvent" handler="OnDeleteEvent" />
1818
<child>
@@ -34,14 +34,38 @@
3434
</packing>
3535
</child>
3636
<child>
37-
<widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow1">
37+
<widget class="Gtk.VPaned" id="vpaned1">
3838
<property name="MemberName" />
39-
<property name="ShadowType">In</property>
39+
<property name="CanFocus">True</property>
40+
<property name="Position">112</property>
41+
<child>
42+
<widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow1">
43+
<property name="MemberName" />
44+
<property name="ShadowType">In</property>
45+
<child>
46+
<widget class="Gtk.NodeView" id="noteslist">
47+
<property name="MemberName" />
48+
<property name="CanFocus">True</property>
49+
<property name="ShowScrollbars">True</property>
50+
</widget>
51+
</child>
52+
</widget>
53+
<packing>
54+
<property name="Resize">False</property>
55+
</packing>
56+
</child>
4057
<child>
41-
<widget class="Gtk.NodeView" id="noteslist">
58+
<widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow">
4259
<property name="MemberName" />
43-
<property name="CanFocus">True</property>
44-
<property name="ShowScrollbars">True</property>
60+
<property name="ShadowType">In</property>
61+
<child>
62+
<widget class="Gtk.TextView" id="editor">
63+
<property name="MemberName" />
64+
<property name="CanFocus">True</property>
65+
<property name="ShowScrollbars">True</property>
66+
<property name="Text" translatable="yes" />
67+
</widget>
68+
</child>
4569
</widget>
4670
</child>
4771
</widget>
@@ -51,21 +75,21 @@
5175
</packing>
5276
</child>
5377
<child>
54-
<widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow">
78+
<widget class="Gtk.Statusbar" id="statusbar">
5579
<property name="MemberName" />
56-
<property name="ShadowType">In</property>
80+
<property name="Spacing">6</property>
5781
<child>
58-
<widget class="Gtk.TextView" id="editor">
59-
<property name="MemberName" />
60-
<property name="CanFocus">True</property>
61-
<property name="ShowScrollbars">True</property>
62-
<property name="Text" translatable="yes" />
63-
</widget>
82+
<placeholder />
83+
</child>
84+
<child>
85+
<placeholder />
6486
</child>
6587
</widget>
6688
<packing>
6789
<property name="Position">2</property>
6890
<property name="AutoSize">True</property>
91+
<property name="Expand">False</property>
92+
<property name="Fill">False</property>
6993
</packing>
7094
</child>
7195
</widget>

0 commit comments

Comments
 (0)