[Dextrose] [PATCH v2] uy#698: Rectifying "Activity-icons not displaying, if notification-messages are shown"

Ajay Garg ajay at activitycentral.com
Wed Dec 21 15:08:47 EST 2011


Note that this patch is to be applied in full, and NOT over the
version-1 patch.

Reverted to the previous-behaviour, wherein the
notification-message-icon is shown at the end of all activity-icons
(Thanks Anish and Estaban).

Note that, simply loading the journal, before setting up the top-panel-frame,
was not working.

Thus, "gio.File.monitor_file" has been used as the signalling mechanism.
The top-panel-frame-setup (wherein the startup-notification-messages may 
be added) gets processed, ONLY after the journal has been set-up.

Signed-off-by: Ajay Garg <ajay at activitycentral.com>
---
 bin/sugar-session                  |   23 +++++++++++++++++++++--
 src/jarabe/frame/activitiestray.py |   18 ++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/bin/sugar-session b/bin/sugar-session
index ee0048d..da9fbcb 100755
--- a/bin/sugar-session
+++ b/bin/sugar-session
@@ -22,6 +22,7 @@ import sys
 import time
 import subprocess
 import shutil
+import gio
 
 if os.environ.get('SUGAR_LOGGER_LEVEL', '') == 'debug':
     print '%r STARTUP: Starting the shell' % time.time()
@@ -36,6 +37,9 @@ import gobject
 import dbus.glib
 import wnck
 
+monitors = []
+monitor_action_taken = False
+
 try:
     import xklavier
 except ImportError:
@@ -182,15 +186,31 @@ def setup_window_manager():
             shell=True):
         logging.warning('Can not disable metacity keybindings')
 
+def file_monitor_changed_cb(monitor, one_file, other_file, event_type):
+    global monitor_action_taken
+    if ( not monitor_action_taken ) and \
+            ( one_file.get_path() == os.path.expanduser('~/.sugar/journal_created') ):
+        if event_type == gio.FILE_MONITOR_EVENT_CREATED:
+            gobject.idle_add(setup_frame_cb)
+            monitor_action_taken = True
+
+def arrange_for_setup_frame_cb():
+    path = gio.File(os.path.expanduser('~/.sugar/journal_created'))
+    monitor = path.monitor_file()
+    monitor.connect('changed', file_monitor_changed_cb)
+    monitors.append(monitor)
+
 def bootstrap():
     setup_window_manager()
 
     from jarabe.view import launcher
     launcher.setup()
 
-    gobject.idle_add(setup_frame_cb)
     gobject.idle_add(setup_keyhandler_cb)
+
+    arrange_for_setup_frame_cb()
     gobject.idle_add(setup_journal_cb)
+
     gobject.idle_add(setup_notification_service_cb)
     gobject.idle_add(setup_file_transfer_cb)
     gobject.idle_add(show_software_updates_cb)
@@ -299,5 +319,4 @@ def _check_for_window_manager(screen):
         screen.disconnect_by_func(__window_manager_changed_cb)
         bootstrap()
 
-
 main()
diff --git a/src/jarabe/frame/activitiestray.py b/src/jarabe/frame/activitiestray.py
index 941b174..e4bf219 100644
--- a/src/jarabe/frame/activitiestray.py
+++ b/src/jarabe/frame/activitiestray.py
@@ -246,6 +246,24 @@ class ActivitiesTray(HTray):
         button.connect('clicked', self.__activity_clicked_cb, home_activity)
         button.show()
 
+        # JournalActivity is always the first activity to be added.
+        # Now, since the message-box is to be always added at the last,
+        # it needs a signal that journal-activity has been added.
+        # We are using "gio.File.monitor" for this purpose.
+        # Thus, create the monitor file.
+        if group is None:
+            monitor_file = os.path.expanduser('~/.sugar/journal_created')
+
+            # Remove the file, if it exists.
+            # This is important, since we are checking for the
+            # FILE_CREATED event in the monitor.
+            if os.path.exists(monitor_file):
+                os.remove(monitor_file)
+
+            # Now, create the file.
+            f = open(monitor_file, 'w')
+            f.close()
+
     def __activity_removed_cb(self, home_model, home_activity):
         logging.debug('__activity_removed_cb: %r', home_activity)
         button = self._buttons[home_activity]
-- 
1.7.4.4



More information about the Dextrose mailing list