Merge lp:~mblayman/entertainer/frontend-cleanup into lp:entertainer

Proposed by Matt Layman
Status: Merged
Approved by: Paul Hummer
Approved revision: 345
Merged at revision: not available
Proposed branch: lp:~mblayman/entertainer/frontend-cleanup
Merge into: lp:entertainer
To merge this branch: bzr merge lp:~mblayman/entertainer/frontend-cleanup
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Review via email: mp+3464@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Matt Layman (mblayman) wrote :

This branch streamlines how the frontend and system tray icon are started. The system tray icon used to have some logic that would start the frontend, but since the icon is nothing more than a different interface to access some features of Entertainer, I've moved it into the FrontentClient. Also, the SystemTrayMessageHandler was doing nothing. There was no interaction with the message bus and message proxy which is what message handlers are supposed to do, so the class was adding no value. Therefore, I've removed it entirely. Additionally, nothing was being displayed by notifications except for debug messages, so notifications are gone now too. If we actually develop a feature that uses them in the future, we can easily bring them back.

I've also taken the simple action of moving the main loop into a different method. This should allow us to *potentially* test the FrontendClient class (although I think that there is still work to done on how to mock the backend connection that is uses).

Hopefully, this branch will greatly clarify the design of the frontend package because I'm sure it was pretty unclear to a casual observer. Refactoring is fun! :)

Revision history for this message
Matt Layman (mblayman) wrote :
Download full text (35.3 KiB)

=== modified file 'cfg/preferences.conf'
--- cfg/preferences.conf 2008-12-17 19:19:33 +0000
+++ cfg/preferences.conf 2009-02-07 00:48:26 +0000
@@ -9,7 +9,6 @@
 theme = Default
 backend_port = 45054
 history_size = 8
-display_notifications = True
 transition_effect = Slide
 start_server_auto = True
 display_icon = False

=== modified file 'docs/DEPENDENCIES'
--- docs/DEPENDENCIES 2009-01-06 23:52:09 +0000
+++ docs/DEPENDENCIES 2009-02-07 00:48:26 +0000
@@ -2,5 +2,5 @@

 sudo apt-get install python-gobject python-gtk2 python-gst0.10 python-clutter \
 python-pysqlite2 python-cddb python-glade2 python-cairo python-feedparser \
-python-eyed3 python-pyvorbis python-imaging python-imdbpy python-notify
+python-eyed3 python-pyvorbis python-imaging python-imdbpy

=== modified file 'entertainerlib/backend/backend_server.py'
--- entertainerlib/backend/backend_server.py 2009-01-31 15:46:36 +0000
+++ entertainerlib/backend/backend_server.py 2009-02-07 00:48:26 +0000
@@ -47,8 +47,6 @@
         self.logger = Logger().getLogger('backend.BackendServer')
         self.message_bus = MessageBus()

- # Notify object - used to display desktop notifications
- self.notifier = None
         # Connection server - Thread that listens incoming socket connections
         self.connection_server = None

=== modified file 'entertainerlib/frontend/__init__.py'
--- entertainerlib/frontend/__init__.py 2008-10-13 16:23:50 +0000
+++ entertainerlib/frontend/__init__.py 2009-02-07 00:48:26 +0000
@@ -5,22 +5,27 @@

     # Import statements are inside thu function so that they aren't imported
     # every time something from the frontend is imported
+ import clutter
+ import gobject
+ import gtk
+
     from entertainerlib.frontend.translation_setup import TranslationSetup
     TranslationSetup()

     from entertainerlib.backend.backend_server import BackendServer
     from entertainerlib.utils.configuration import Configuration
     from entertainerlib.frontend.frontend_client import FrontendClient
- from entertainerlib.utils.system_tray_icon import init_systray
+
+ gobject.threads_init()
+ gtk.gdk.threads_init()
+ clutter.threads_init()

     config = Configuration()
     if config.start_auto_server():
         print "Entertainer backend starting..."
         backend = BackendServer()

- if config.tray_icon_enabled():
- init_systray()
- else:
- FrontendClient()
+ frontend_client = FrontendClient()
+ frontend_client.start()

=== modified file 'entertainerlib/frontend/frontend_client.py'
--- entertainerlib/frontend/frontend_client.py 2009-01-31 15:46:36 +0000
+++ entertainerlib/frontend/frontend_client.py 2009-02-07 00:48:26 +0000
@@ -1,139 +1,97 @@
 '''Entertainer Frontend - This is a client side of Entertainer.'''

-__licence__ = "GPLv2"
-__copyright__ = "2007, Lauri Taimila"
-__author__ = "Lauri Taimila <email address hidden>"
-__version__ = "0.1"
+__licence__ = 'GPLv2'
+__copyright__ = ('2007, Lauri Taimila', '2009, Matt Layman')
+__author__ = ('Lauri Taimila <email address hidden>',
+ 'Matt Layman <email address hidden>')

 import sys

-from entertainerlib.utils.configuration import Confi...

Revision history for this message
Matt Layman (mblayman) wrote :

By the way, for those who are interested, here are some stats on the diff (a la diffstat):

 cfg/preferences.conf | 1
 docs/DEPENDENCIES | 2
 entertainerlib/backend/backend_server.py | 2
 entertainerlib/frontend/__init__.py | 15
 entertainerlib/frontend/frontend_client.py | 152 +++-----
 entertainerlib/frontend/gui/user_interface.py | 43 --
 entertainerlib/tests/test_configuration.py | 4
 entertainerlib/tests/test_systemtraymessagehandler.py | 168 ---------
 entertainerlib/utils/configuration.py | 12
 entertainerlib/utils/glade/entertainer-preferences.glade | 14
 entertainerlib/utils/preferences_dialog.py | 15
 entertainerlib/utils/system_tray_icon.py | 255 ---------------
 12 files changed, 93 insertions(+), 590 deletions(-)

Revision history for this message
Paul Hummer (rockstar) wrote :

Matt-

  Good branch. It was big, but most of it was just removing code (which I
didn't see initially). I just have two nitpicks with docstrings. That's it.

 vote approve
 status approved

> === modified file 'entertainerlib/frontend/frontend_client.py'
> --- entertainerlib/frontend/frontend_client.py 2009-01-31 15:46:36
> +0000 +++ entertainerlib/frontend/frontend_client.py 2009-02-07
> 00:48:26 +0000 @@ -1,139 +1,97 @@
> def quit_frontend(self):
> - """
> + '''
> Quit Frontend
>
> This is called when user closes frontend. Before closing application
> - the backend connection etc. are closed in a clean way."""
> + the backend connection etc. are closed in a clean way.'''

This docstring is a bit verbose for what it does. It could easily be a one
liner.

> === modified file 'entertainerlib/frontend/gui/user_interface.py'
> --- entertainerlib/frontend/gui/user_interface.py 2009-02-04 00:01:22
> +0000 +++ entertainerlib/frontend/gui/user_interface.py 2009-02-07
> @@ -132,10 +126,9 @@
> }
> self.move_to_new_screen("question", kwargs)
>
> - def start_up(self, fullscreen):
> + def start_up(self):
> """
> This is called once when Entertainer is starting up.
> - @param fullscreen: Should we start in fullscreen mode
> """
> self.show()
> self.current = self.create_screen("main")

Could you put this docstring on one line?

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

review: Approve
Revision history for this message
Matt Layman (mblayman) wrote :

"Matt-

  Good branch. It was big, but most of it was just removing code (which I
didn't see initially). I just have two nitpicks with docstrings. That's it.

 vote approve
 status approved

> === modified file 'entertainerlib/frontend/frontend_client.py'
> --- entertainerlib/frontend/frontend_client.py 2009-01-31 15:46:36
> +0000 +++ entertainerlib/frontend/frontend_client.py 2009-02-07
> 00:48:26 +0000 @@ -1,139 +1,97 @@
> def quit_frontend(self):
> - """
> + '''
> Quit Frontend
>
> This is called when user closes frontend. Before closing application
> - the backend connection etc. are closed in a clean way."""
> + the backend connection etc. are closed in a clean way.'''

This docstring is a bit verbose for what it does. It could easily be a one
liner.

> === modified file 'entertainerlib/frontend/gui/user_interface.py'
> --- entertainerlib/frontend/gui/user_interface.py 2009-02-04 00:01:22
> +0000 +++ entertainerlib/frontend/gui/user_interface.py 2009-02-07
> @@ -132,10 +126,9 @@
> }
> self.move_to_new_screen("question", kwargs)
>
> - def start_up(self, fullscreen):
> + def start_up(self):
> """
> This is called once when Entertainer is starting up.
> - @param fullscreen: Should we start in fullscreen mode
> """
> self.show()
> self.current = self.create_screen("main")

Could you put this docstring on one line?

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F
"

Ha, of course it's for doc strings that I didn't write :). I'll fix these up and push up a fix. I'll post the partial diff when I'm done.

346. By Matt Layman

Updated doc strings

Revision history for this message
Matt Layman (mblayman) wrote :

Partial diff:

=== modified file 'entertainerlib/frontend/frontend_client.py'
--- entertainerlib/frontend/frontend_client.py 2009-02-07 00:28:11 +0000
+++ entertainerlib/frontend/frontend_client.py 2009-02-07 19:36:01 +0000
@@ -71,11 +71,7 @@
         return backend_connection

     def quit_frontend(self):
- '''
- Quit Frontend
-
- This is called when user closes frontend. Before closing application
- the backend connection etc. are closed in a clean way.'''
+ '''Clean up the connection to the backend then close the frontend.'''
         try:
             self.backend_connection.close_connection()
         except Exception, e:

=== modified file 'entertainerlib/frontend/gui/user_interface.py'
--- entertainerlib/frontend/gui/user_interface.py 2009-02-07 00:28:11 +0000
+++ entertainerlib/frontend/gui/user_interface.py 2009-02-07 19:42:25 +0000
@@ -127,9 +127,7 @@
         self.move_to_new_screen("question", kwargs)

     def start_up(self):
- """
- This is called once when Entertainer is starting up.
- """
+ '''Start the user interface and make it visible.'''
         self.show()
         self.current = self.create_screen("main")
         self.transition.forward_effect(None, self.current)

Subscribers

People subscribed via source and target branches