Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'widgets.py')
-rw-r--r--widgets.py63
1 files changed, 56 insertions, 7 deletions
diff --git a/widgets.py b/widgets.py
index 821b60c..1f3cff9 100644
--- a/widgets.py
+++ b/widgets.py
@@ -20,10 +20,14 @@
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
+from gi.repository import GObject
import os
from sugar3.activity import activity
from sugar3.graphics import style
+from sugar3.graphics.icon import Icon
+
+from gettext import gettext as _
ICONS_DIR = os.path.join(activity.get_bundle_path(), "icons")
@@ -44,7 +48,7 @@ class DeviceList(Gtk.TreeView):
self.model = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)
self.set_model(self.model)
- column = Gtk.TreeViewColumn()
+ column = Gtk.TreeViewColumn('Devices')
cell = Gtk.CellRendererPixbuf()
column.pack_start(cell, False)
column.add_attribute(cell, "pixbuf", 0)
@@ -52,14 +56,14 @@ class DeviceList(Gtk.TreeView):
column = Gtk.TreeViewColumn()
cell = Gtk.CellRendererText()
- column.pack_start(cell, False)
- column.add_attribute(cell, "text", 1)
+ column.pack_start(cell, True)
+ column.add_attribute(cell, "markup", 1)
self.append_column(column)
column = Gtk.TreeViewColumn()
cell = Gtk.CellRendererText()
column.pack_start(cell, False)
- column.add_attribute(cell, "text", 2)
+ column.add_attribute(cell, "markup", 2)
self.append_column(column)
#self.modify_base(Gdk.Color(255, 255, 255))
@@ -67,9 +71,54 @@ class DeviceList(Gtk.TreeView):
def add_device(self, i):
icon = get_icon(i["Icon"])
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon,
- style.MEDIUM_ICON_SIZE, style.MEDIUM_ICON_SIZE)
- self.model.append([pixbuf, i["Name"], i["Address"]])
+ style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
+ self.model.append([pixbuf, '<b>%s</b>' % i["Name"],
+ '<b>%s</b>' % i["Address"]])
def set_devices(self, devices):
for i in devices:
- self.add_device(i) \ No newline at end of file
+ self.add_device(i)
+
+
+class EmptyWidgets(Gtk.EventBox):
+
+ __gsignals__ = {
+ 'search-again': (GObject.SignalFlags.RUN_FIRST, None, [])}
+
+ def __init__(self):
+ Gtk.EventBox.__init__(self)
+
+ self.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,
+ file='activity/activity-bluetooth.svg',
+ 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 devices found')))
+ label.set_use_markup(True)
+ mvbox.pack_start(label, False, False, style.DEFAULT_PADDING)
+
+ hbox = Gtk.Box()
+ search_btn = Gtk.Button()
+ search_btn.connect('clicked', lambda w: self.emit('search-again'))
+ refresh_image = Gtk.Image.new_from_stock(Gtk.STOCK_REFRESH,
+ Gtk.IconSize.BUTTON)
+ buttonbox = Gtk.Box()
+ buttonbox.pack_start(refresh_image, False, True, 0)
+ buttonbox.pack_end(Gtk.Label(_('Search again')), True, True, 5)
+ search_btn.add(buttonbox)
+ hbox.pack_start(search_btn, True, False, 0)
+ mvbox.pack_start(hbox, False, False, style.DEFAULT_PADDING)
+
+ self.add(vbox)
+ self.show_all()
+