[Sugar-devel] [PATCH sugar 17/20] Use underscore consistently

Daniel Narvaez dwnarvaez at gmail.com
Mon Dec 10 14:11:43 EST 2012


From: Daniel Narvaez <dwnarvaez at gmail.com>

---
 src/jarabe/main.py |   63 +++++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/src/jarabe/main.py b/src/jarabe/main.py
index ceda4f8..02e0011 100755
--- a/src/jarabe/main.py
+++ b/src/jarabe/main.py
@@ -67,13 +67,13 @@ from jarabe.intro.window import IntroWindow
 from jarabe import frame
 from jarabe.view.service import UIService
 
-def check_software_updates():
+def _check_software_updates():
     logging.debug('STARTUP: check_software_updates')
     if os.path.isfile(os.path.expanduser('~/.sugar-update')):
         home_window = homewindow.get_instance()
         home_window.get_home_box().show_software_updates_alert()
 
-def setup_window_manager():
+def _setup_window_manager():
     logging.debug('STARTUP: window_manager')
 
     if subprocess.call('metacity-message disable-keybindings',
@@ -84,8 +84,17 @@ def setup_window_manager():
                        shell=True):
         logging.warning('Can not disable metacity mouse button modifiers')
 
-def bootstrap():
-    setup_window_manager()
+def _window_manager_changed_cb(screen):
+    _check_for_window_manager(screen)
+
+def _check_for_window_manager(screen):
+    wm_name = screen.get_window_manager_name()
+    if wm_name is not None:
+        screen.disconnect_by_func(_window_manager_changed_cb)
+        _bootstrap()
+
+def _bootstrap():
+    _setup_window_manager()
 
     launcher.setup()
     keyboard.setup()
@@ -98,16 +107,16 @@ def bootstrap():
 
     journalactivity.start()
 
-    check_software_updates()
+    _check_software_updates()
 
-def setup_fonts():
+def _setup_fonts():
     client = GConf.Client.get_default()
     face = client.get_string('/desktop/sugar/font/default_face')
     size = client.get_float('/desktop/sugar/font/default_size')
     settings = Gtk.Settings.get_default()
     settings.set_property("gtk-font-name", "%s %f" % (face, size))
 
-def setup_theme():
+def _setup_theme():
     settings = Gtk.Settings.get_default()
     sugar_theme = 'sugar-72'
     if 'SUGAR_SCALING' in os.environ:
@@ -119,7 +128,7 @@ def setup_theme():
     icons_path = os.path.join(config.data_path, 'icons')
     Gtk.IconTheme.get_default().append_search_path(icons_path)
 
-def start_home():
+def _start_home():
     ui_service = UIService()
 
     session_manager = get_session_manager()
@@ -130,13 +139,13 @@ def start_home():
     home_window.show()
 
     screen = Wnck.Screen.get_default()
-    screen.connect('window-manager-changed', __window_manager_changed_cb)
+    screen.connect('window-manager-changed', _window_manager_changed_cb)
     _check_for_window_manager(screen)
 
-def intro_window_done_cb(window):
-    start_home()
+def _intro_window_done_cb(window):
+    _start_home()
 
-def cleanup_temporary_files():
+def _cleanup_temporary_files():
     try:
         # Remove temporary files. See http://bugs.sugarlabs.org/ticket/1876
         data_dir = os.path.join(env.get_profile_path(), 'data')
@@ -147,7 +156,7 @@ def cleanup_temporary_files():
         # sugar from starting if (for example) the disk is full or read-only.
         print 'temporary files cleanup failed: %s' % e
 
-def setup_locale():
+def _setup_locale():
     # NOTE: This needs to happen early because some modules register
     # translatable strings in the module scope.
     gettext.bindtextdomain('sugar', config.locale_path)
@@ -159,22 +168,22 @@ def setup_locale():
     if timezone is not None and timezone:
         os.environ['TZ'] = timezone
 
-def main():
+def _main():
     GLib.threads_init()
     Gdk.threads_init()
     dbus.glib.threads_init()
     Gst.init(sys.argv)
 
-    cleanup_temporary_files()
+    _cleanup_temporary_files()
 
-    setup_locale()
+    _setup_locale()
 
     client = GConf.Client.get_default()
     client.set_string('/apps/metacity/general/mouse_button_modifier',
                       '<Super>')
 
-    setup_fonts()
-    setup_theme()
+    _setup_fonts()
+    _setup_theme()
 
     # this must be added early, so that it executes and unfreezes the screen
     # even when we initially get blocked on the intro screen
@@ -192,26 +201,14 @@ def main():
 
     if not intro.check_profile():
         win = IntroWindow()
-        win.connect("done", intro_window_done_cb)
+        win.connect("done", _intro_window_done_cb)
         win.show_all()
     else:
-        start_home()
+        _start_home()
 
     try:
         Gtk.main()
     except KeyboardInterrupt:
         print 'Ctrl+C pressed, exiting...'
 
-
-def __window_manager_changed_cb(screen):
-    _check_for_window_manager(screen)
-
-
-def _check_for_window_manager(screen):
-    wm_name = screen.get_window_manager_name()
-    if wm_name is not None:
-        screen.disconnect_by_func(__window_manager_changed_cb)
-        bootstrap()
-
-
-main()
+_main()
-- 
1.7.10.4



More information about the Sugar-devel mailing list