Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Tamagtochi Widget #852

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
12 changes: 10 additions & 2 deletions src/jarabe/view/buddyicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ def __init__(self, buddy, pixel_size=style.STANDARD_ICON_SIZE):
self.journal_entries = 0
self.has_battery = None
self.__tamagotchi_thread()
_, self.journal_entries = datastore.find({})
datastore.updated.connect(self.__datastore_listener_updated_cb)
datastore.deleted.connect(self.__datastore_listener_deleted_cb)

def __tamagotchi_thread(self):
GLib.timeout_add(60000, self.__tamagotchi_thread)
self.__datastore_query()

user_type = None
disk_space_type = None
Expand All @@ -95,6 +97,12 @@ def __tamagotchi_thread(self):
self.__get_battery()
self.__status_tooltip(self.has_battery)

def __datastore_listener_updated_cb(self, **kwargs):
self.journal_entries += 1

def __datastore_listener_deleted_cb(self, **kwargs):
self.journal_entries -= 1

def __get_battery(self):
settings = Gio.Settings('org.sugarlabs.power')
self.has_battery = settings.get_boolean('battery-present')
Expand All @@ -109,7 +117,7 @@ def __get_battery(self):
def __status_tooltip(self, has_battery=False):
disk_usage = (self.used * 100) / self.total
battery = ''
if has_battery:
if self.has_battery:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your change here to use self.has_battery means the keyword argument is not needed?

battery = "\n{} Battery".format(str(self.level))
tooltip_str = "{}% Disk space used {}".format(str(disk_usage), battery)
self.set_tooltip_text(tooltip_str)
Expand Down