On Sun, 20 Jul 2014 04:00:09 -0700 Kai Huuhko <[email protected]> said:

you know that elementary automatically disabled evas rendering (turns on manual
render) when withdrawn? you don't have to do anything... and it does it for all
your windows. it also can add ecore_throttle values too to force the mainloop
to usleep() for some small bit of time - all in elm config.

> kuuko pushed a commit to branch master.
> 
> http://git.enlightenment.org/apps/epour.git/commit/?id=1fe0cf1b843441ff8acc4eb141e114433fab0688
> 
> commit 1fe0cf1b843441ff8acc4eb141e114433fab0688
> Author: Kai Huuhko <[email protected]>
> Date:   Sun Jul 20 13:59:30 2014 +0300
> 
>     Pause gui updates when iconized/withdrawn
> ---
>  TODO                      |  2 +-
>  epour/gui/TorrentProps.py | 13 +++++++++++--
>  epour/gui/__init__.py     | 13 +++++++++++++
>  epour/session.py          |  3 +++
>  4 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/TODO b/TODO
> index d5831a3..bc3d4b3 100644
> --- a/TODO
> +++ b/TODO
> @@ -42,7 +42,7 @@ Misc:
>   ☐ Save torrent & resume data periodically
>     http://libtorrent.org/reference-Core.html#save_resume_data()
>     http://libtorrent.org/reference-Core.html#need_save_resume_data()
> - ☐ Pause gui updates when iconized
> + ✔ Pause gui updates when iconized/withdrawn @done (13:58 20.07.2014)
>  Error handling:
>   ☐ Torrent errors
>     http://libtorrent.org/reference-Alerts.html#torrent_error_alert
> diff --git a/epour/gui/TorrentProps.py b/epour/gui/TorrentProps.py
> index c233c17..58f75d3 100644
> --- a/epour/gui/TorrentProps.py
> +++ b/epour/gui/TorrentProps.py
> @@ -25,7 +25,7 @@ import os
>  import pipes
>  from datetime import datetime, timedelta
>  import logging
> -log = logging.getLogger("epour")
> +log = logging.getLogger("epour.gui")
>  
>  import libtorrent as lt
>  
> @@ -222,12 +222,17 @@ class TorrentFiles(StandardWindow):
>          filelist.data["progress"] = h.file_progress()
>  
>          def update_progress(h):
> +            #log.debug("File progress TICK")
>              filelist.data["progress"] = h.file_progress()
>              for it in filelist.realized_items:
>                  it.fields_update("*", ELM_GENLIST_ITEM_FIELD_TEXT)
>              return True
>  
> -        ecore.Timer(5.0, update_progress, h)
> +        timer = ecore.Timer(5.0, update_progress, h)
> +        self.on_del_add(lambda x: timer.delete())
> +        self.callback_withdrawn_add(lambda x: timer.freeze())
> +        self.callback_iconified_add(lambda x: timer.freeze())
> +        self.callback_normal_add(lambda x: timer.thaw())
>  
>          filelist.callback_expand_request_add(self.expand_request_cb)
>          filelist.callback_contract_request_add(self.contract_request_cb)
> @@ -616,6 +621,7 @@ class TorrentStatus(Table):
>              i += 1
>  
>          def update():
> +            #log.debug("Torrent status TICK")
>              s = h.status()
>              for w in self.widgets:
>                  key = w.data["key"]
> @@ -626,6 +632,9 @@ class TorrentStatus(Table):
>  
>          timer = ecore.Timer(5.0, update)
>          self.on_del_add(lambda x: timer.delete())
> +        self.top_widget.callback_withdrawn_add(lambda x: timer.freeze())
> +        self.top_widget.callback_iconified_add(lambda x: timer.freeze())
> +        self.top_widget.callback_normal_add(lambda x: timer.thaw())
>  
>      @staticmethod
>      def populate(w, v):
> diff --git a/epour/gui/__init__.py b/epour/gui/__init__.py
> index ff17401..3380235 100644
> --- a/epour/gui/__init__.py
> +++ b/epour/gui/__init__.py
> @@ -234,10 +234,14 @@ class MainInterface(object):
>  
>          self.timer = Timer(1.0, self.update)
>          self.win.on_del_add(lambda x: self.timer.delete())
> +        self.win.callback_withdrawn_add(lambda x: self.timer.freeze())
> +        self.win.callback_iconified_add(lambda x: self.timer.freeze())
> +        self.win.callback_normal_add(lambda x: self.timer.thaw())
>          elm.run()
>          elm.shutdown()
>  
>      def update(self):
> +        #log.debug("Torrent list TICK")
>          for v in self.tlist.realized_items_get():
>              v.fields_update("*", ELM_GENLIST_ITEM_FIELD_TEXT)
>          return True
> @@ -373,8 +377,16 @@ class SessionStatus(Table):
>  
>          self.update_timer = Timer(1.0, self.update)
>          self.on_del_add(lambda x: self.update_timer.delete())
> +        self.top_widget.callback_withdrawn_add(
> +            lambda x: self.update_timer.freeze()
> +            )
> +        self.top_widget.callback_iconified_add(
> +            lambda x: self.update_timer.freeze()
> +            )
> +        self.top_widget.callback_normal_add(lambda x: self.update_timer.thaw
> ()) 
>      def update(self):
> +        #log.debug("Session status TICK")
>          s = self.session.status()
>          self.d_l.text = "{}/s".format(intrepr(s.payload_download_rate))
>          self.u_l.text = "{}/s".format(intrepr(s.payload_upload_rate))
> @@ -644,6 +656,7 @@ class TorrentTooltip(Table):
>  
>      @staticmethod
>      def update(h, items, value_labels, g):
> +        #log.debug("Tooltip TICK")
>          s = h.status(8)
>          for i, l in enumerate(value_labels):
>              conv, attr_name = items[i][1:]
> diff --git a/epour/session.py b/epour/session.py
> index d869736..37df9ff 100644
> --- a/epour/session.py
> +++ b/epour/session.py
> @@ -385,6 +385,7 @@ class AlertManager(object):
>      def __init__(self, session):
>          self.session = session
>  
> +        # TODO: Use the lt alert interval from session settings here?
>          self.timer = Timer(self.update_interval, self.update)
>  
>      def callback_add(self, alert_type, cb, *args, **kwargs):
> @@ -411,6 +412,8 @@ class AlertManager(object):
>                  self.log.exception("Exception while handling alerts")
>  
>      def update(self):
> +        # TODO: Use pop_alerts()
> +        #self.log.debug("Alerts TICK")
>          while 1:
>              a = self.session.pop_alert()
>              if not a:
> 
> -- 
> 
> 


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    [email protected]


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to