140
139
string plus = (balance > 0) ? "+" : "";
142
141
(cell as Gtk.CellRendererText).Weight = 10000000;
142
(cell as Gtk.CellRendererText).Alignment = Pango.Alignment.Right;
143
143
(cell as Gtk.CellRendererText).Text = plus + string.Format("{0:0.00}", balance);
147
private void loadData()
149
_store.AppendValues (new Transaction(0d, "Start balancing", DateTime.Now), 0d);
151
_store.AppendValues (new Transaction(-1.20, "test", DateTime.Now),-1.2);
152
_store.AppendValues (new Transaction(1.23, "test", DateTime.Now),0.23);
156
protected virtual void OnDataViewButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
158
if (args.Event.Type == Gdk.EventType.ButtonPress && args.Event.Button == 3)
160
Menu context = new Menu();
161
ImageMenuItem edit = new ImageMenuItem(Stock.Edit, null);
162
edit.Activated += new EventHandler(ContextMenUEditActivated);
164
context.Append(edit);
166
System.Console.WriteLine("cooler");
168
PopupContextMenuAtLocation(context, (int)args.Event.X, (int)args.Event.Y);
172
void PopupContextMenuAtLocation (Gtk.Menu menu, int x, int y)
175
Gtk.MenuPositionFunc pos_menu_func = null;
177
// Set up the funtion to position the context menu
178
// if we were called by the keyboard Gdk.Key.Menu.
179
if (x == 0 && y == 0)
180
pos_menu_func = PositionContextMenu;
182
menu.Popup (null, null, pos_menu_func, 0, Gtk.Global.CurrentEventTime);
185
// This is needed for when the user opens
186
// the context menu with the keyboard.
187
void PositionContextMenu (Gtk.Menu menu, out int x, out int y, out bool push_in)
191
Gtk.TreeSelection selection;
193
// Set default "return" values
194
push_in = false; // not used
198
selection = dataView.Selection;
199
if (!selection.GetSelected (out iter))
202
path = _filter.GetPath (iter);
207
GetWidgetScreenPos (dataView, ref pos_x, ref pos_y);
208
Gdk.Rectangle cell_rect = dataView.GetCellArea (path, dataView.Columns [0]);
210
// Add 100 to x so it's not be at the far left
211
x = pos_x + cell_rect.X + 100;
212
y = pos_y + cell_rect.Y;
215
// Walk the widget hiearchy to figure out
216
// where to position the context menu.
217
void GetWidgetScreenPos (Gtk.Widget widget, ref int x, ref int y)
222
if (widget is Gtk.Window)
224
((Gtk.Window) widget).GetPosition (out widget_x, out widget_y);
227
GetWidgetScreenPos (widget.Parent, ref x, ref y);
229
// Special case the TreeView because it adds
230
// too much since it's in a scrolled window.
231
if (widget == dataView)
237
Gdk.Rectangle widget_rect = widget.Allocation;
238
widget_x = widget_rect.X;
239
widget_y = widget_rect.Y;
247
void ContextMenUEditActivated(object o, EventArgs args)
251
if (dataView.Selection.GetSelected(out iter))
253
Transaction item = (Transaction)_filter.GetValue(iter, 0);
255
TransactionDialog dialog = new TransactionDialog(item);
257
//TODO: Handle editing
259
if (dialog.Run() == (int)(ResponseType.Ok))
261
Transaction t = dialog.Current;
262
//TODO: also store in Account or implement account usen liststore
263
_store.AppendValues(t);
147
270
private void showNewTransactionDialog()
240
369
private bool searchItems(Transaction trans)
242
System.Console.WriteLine("#####");
243
System.Console.WriteLine(_searchText);
245
if (_searchText == "")
248
if (trans.Date.ToShortDateString().Contains(_searchText))
251
if (trans.Amount.ToString().Contains(_searchText))
371
string searchText = searchEntry.Text;
373
if (searchText == "")
376
if (trans.Date.ToShortDateString().Contains(searchText))
379
if (trans.Amount.ToString().Contains(searchText))
254
return trans.Description.Contains(_searchText);
257
protected virtual void OnSearchEntryChanged (object sender, System.EventArgs e)
259
Entry search = sender as Entry;
261
string mask = search.Text;
382
return trans.Description.Contains(searchText);