Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2014-07-08 16:37:58 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2014-07-08 16:37:58 (GMT)
commitd201e867930666c627db1a6d5b87f969dfd1e401 (patch)
treeaf467a73307128f97e74e9662d7d805101d6d0c0
parentcf97eff016ec0bd4fe66ce44e5d1fe407e5d009a (diff)
Add graphic of credit
-rw-r--r--chartscreen.py32
-rw-r--r--finance.py2
2 files changed, 26 insertions, 8 deletions
diff --git a/chartscreen.py b/chartscreen.py
index f5e821a..94f765d 100644
--- a/chartscreen.py
+++ b/chartscreen.py
@@ -38,6 +38,10 @@ CHART_HELP = _(
class ChartScreen(Gtk.VBox):
+
+ CHART_CREDIT = 'credit'
+ CHART_DEBIT = 'debit'
+
def __init__(self, activity):
GObject.GObject.__init__(self)
@@ -45,19 +49,17 @@ class ChartScreen(Gtk.VBox):
self.category_total = {}
self.sorted_categories = []
+ self._graph_mode = self.CHART_DEBIT
header = Gtk.EventBox()
header.modify_bg(Gtk.StateType.NORMAL,
style.Color('#666666').get_gdk_color())
header.set_size_request(-1, style.GRID_CELL_SIZE)
- label = Gtk.Label()
- label.set_markup(
- '<span size="x-large" foreground="white"><b>%s</b></span>' %
- _('Debit Categories'))
- label.set_halign(Gtk.Align.START)
- label.props.margin_left = style.GRID_CELL_SIZE / 2
- header.add(label)
+ self._title_label = Gtk.Label()
+ self._title_label.set_halign(Gtk.Align.START)
+ self._title_label.props.margin_left = style.GRID_CELL_SIZE / 2
+ header.add(self._title_label)
box = Gtk.HBox()
@@ -82,14 +84,28 @@ class ChartScreen(Gtk.VBox):
self.show_all()
+ def set_mode(self, mode):
+ self._graph_mode = mode
+ self.build()
+
def build(self):
+
+ if self._graph_mode == self.CHART_CREDIT:
+ title = _('Credit Categories')
+ elif self._graph_mode == self.CHART_DEBIT:
+ title = _('Debit Categories')
+
+ self._title_label.set_markup(
+ '<span size="x-large" foreground="white"><b>%s</b></span>' %
+ title)
+
# Build the category totals.
self.category_total = {}
for t in self.activity.visible_transactions:
cat = t['category']
amount = t['amount']
- if t['type'] == 'debit':
+ if t['type'] == self._graph_mode:
if cat not in self.category_total:
self.category_total[cat] = amount
else:
diff --git a/finance.py b/finance.py
index 57923a7..69cf2eb 100644
--- a/finance.py
+++ b/finance.py
@@ -345,6 +345,7 @@ class Finance(Activity):
def __newcredit_cb(self, widget):
if self._active_panel == self.chart:
# in the case of chart, select the graphic
+ self.chart.set_mode(self.chart.CHART_CREDIT)
return
# this check is used when the emptypanle is visible
@@ -355,6 +356,7 @@ class Finance(Activity):
def __newdebit_cb(self, widget):
if self._active_panel == self.chart:
# in the case of chart, select the graphic
+ self.chart.set_mode(self.chart.CHART_DEBIT)
return
# this check is used when the emptypanle is visible