Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-11-09 17:42:42 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-11-10 00:40:04 (GMT)
commit0d94ff672a4b076cc98058524d78d814e4aa7704 (patch)
tree1c0c53c34c100b3ddef9641734e967cd0ea50750
parentf99886896accc3b5473d9d870c20ccadb9c9e99e (diff)
Show No data message
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
-rw-r--r--activity.py60
-rw-r--r--icons/chart.svg66
2 files changed, 123 insertions, 3 deletions
diff --git a/activity.py b/activity.py
index c7e48a1..b9aaab1 100644
--- a/activity.py
+++ b/activity.py
@@ -46,6 +46,7 @@ from sugar3.graphics.style import Color
from sugar3.graphics.icon import Icon
from sugar3.graphics.alert import Alert
from sugar3.datastore import datastore
+from sugar3.graphics import style
from readers import StopWatchReader
from readers import MeasureReader
@@ -346,17 +347,65 @@ class ChartActivity(activity.Activity):
# CHARTS AREA
eventbox = Gtk.EventBox()
self.charts_area = ChartArea(self)
- self.charts_area.connect('size_allocate', self._chart_size_allocate)
eventbox.modify_bg(Gtk.StateType.NORMAL, _WHITE)
-
eventbox.add(self.charts_area)
- paned.add2(eventbox)
+
+ self._notebook = Gtk.Notebook()
+ self._notebook.set_property('show-tabs', False)
+ self._notebook.append_page(eventbox, Gtk.Label())
+
+ # EMPTY WIDGETS
+ empty_widgets = Gtk.EventBox()
+ empty_widgets.modify_bg(Gtk.StateType.NORMAL,
+ style.COLOR_WHITE.get_gdk_color())
+
+ vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+ mvbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+ vbox.pack_start(mvbox, True, False, 0)
+
+ image_icon = Icon(pixel_size=style.LARGE_ICON_SIZE,
+ icon_name='chart',
+ stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
+ fill_color=style.COLOR_TRANSPARENT.get_svg())
+ mvbox.pack_start(image_icon, False, False, style.DEFAULT_PADDING)
+
+ label = Gtk.Label('<span foreground="%s"><b>%s</b></span>' %
+ (style.COLOR_BUTTON_GREY.get_html(),
+ _('No data')))
+ label.set_use_markup(True)
+ mvbox.pack_start(label, False, False, style.DEFAULT_PADDING)
+
+ hbox = Gtk.Box()
+ open_image_btn = Gtk.Button()
+ open_image_btn.connect('clicked', self._add_value)
+ add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
+ Gtk.IconSize.BUTTON)
+ buttonbox = Gtk.Box()
+ buttonbox.pack_start(add_image, False, True, 0)
+ buttonbox.pack_end(Gtk.Label(_('Add a value')), True, True, 5)
+ open_image_btn.add(buttonbox)
+ hbox.pack_start(open_image_btn, True, False, 0)
+ mvbox.pack_start(hbox, False, False, style.DEFAULT_PADDING)
+
+ empty_widgets.add(vbox)
+ empty_widgets.show_all()
+ self._notebook.append_page(empty_widgets, Gtk.Label())
+
+ paned.add2(self._notebook)
self.set_canvas(paned)
+ self.charts_area.connect('size_allocate', self._chart_size_allocate)
self.show_all()
+ def _show_empty_widgets(self):
+ self._notebook.set_current_page(1)
+
+ def _show_chart_area(self):
+ if self._notebook.get_current_page() == 1:
+ self._notebook.set_current_page(0)
+
def _create_measure_palette(self, button):
palette = button.get_palette()
hbox = Gtk.HBox()
@@ -409,6 +458,10 @@ class ChartActivity(activity.Activity):
activity.Activity.fullscreen(self)
def _render_chart(self, fullscreen=False):
+ if not self.chart_data:
+ self._show_empty_widgets()
+ return
+
if self.current_chart is None or self.charts_area is None:
return
@@ -442,6 +495,7 @@ class ChartActivity(activity.Activity):
except (ZeroDivisionError, ValueError):
pass
+ self._show_chart_area()
return False
def _update_chart_data(self):
diff --git a/icons/chart.svg b/icons/chart.svg
new file mode 100644
index 0000000..4d06f10
--- /dev/null
+++ b/icons/chart.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY fill_color "#808080">
+ <!ENTITY stroke_color "#FFFFFF">
+]>
+<svg
+ xmlns="http://www.w3.org/2000/svg"
+ version="1.1"
+ width="62"
+ height="60"
+ viewBox="0 0 62 60"
+ id="svg2"
+ xml:space="preserve"><g
+ transform="translate(60.127119,11.292373)"
+ id="activity-browse"
+ style="display:block">
+
+ <g
+ transform="translate(-128.87712,-22.838983)"
+ id="g7"
+ style="display:inline">
+
+
+
+
+
+
+ <g
+ transform="matrix(0.10822504,0,0,0.09945444,61.358446,34.085169)"
+ id="g6167"><g
+ transform="translate(2.7213003,-2.9469823)"
+ id="g3798"
+ style="fill:&fill_color;;fill-opacity:1"><rect
+ width="81.443176"
+ height="272.19876"
+ rx="4.3524833"
+ ry="6.0284276"
+ x="373.97116"
+ y="55.900478"
+ id="rect2987"
+ style="color:#000000;fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:33.73588181;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /><rect
+ width="81.443077"
+ height="360.47952"
+ rx="4.3524833"
+ ry="6.0284276"
+ x="499.32275"
+ y="-32.380226"
+ id="rect3757"
+ style="color:#000000;fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:33.73588181;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /><rect
+ width="81.443077"
+ height="500.25723"
+ rx="4.3524833"
+ ry="6.0284276"
+ x="248.61969"
+ y="-172.15802"
+ id="rect3759"
+ style="color:#000000;fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:33.73588181;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /><rect
+ width="81.443314"
+ height="215.79736"
+ rx="4.3524833"
+ ry="6.0284276"
+ x="123.26795"
+ y="112.30204"
+ id="rect3761"
+ style="color:#000000;fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:33.73588181;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /></g></g></g>
+</g></svg> \ No newline at end of file