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

Anish Mangal anish at sugarlabs.org
Tue Jan 31 08:32:18 EST 2012


Ping. Could somebody review this please :-)

On Tue, Jan 24, 2012 at 10:35, Ajay Garg <ajay at activitycentral.com> wrote:
> ---
>
> Issue:
> ------
> Originally discussed at :
> http://lists.sugarlabs.org/archive/dextrose/2011-August/001340.html
>
> and catched by Esteban Bordón, the issue is that whenever (and not just
> at startup) any notification-messages are displayed, any Activity-icon
> (and not just the Journal-Activity icon) is not displayed in the
> top-panel-frame.
>
> Technical history/details:
> ---------------------------
>
> The mesh-, group-, home-, and activity-zoom buttons are a group of
> radiobuttons; only one may be visibly-active at a time (this is
> highlighted by the white-background of the corresponding selected
> zoom-button).
> Please see:
>               "src/jarabe/frame/zoomtoolbar.py"
> for code-details.
>
> Similarly, all the opened activity-instances are shown by a yet another
> group of radiobuttons; the selected activity being highlighed by the
> corresponding selected activity-icon-button.
>
> Now, what was happening, was that the notification-message-icon was
> being added into the Activities-Tray (the second group of radiobuttons
> as discussed above); but any further activity-icons were not being added
> into the tray, because the notification-message-icon did not respect the
> semantics of the activity-icons. Hence, the notification-message-icon, and
> any other activity-icon (including Journal-activity icon) were not being
> made a part of the same group.
>
> Fix:
> ----
>
> The top-panel-frame-setup (wherein the startup-notification-messages may
> be added) gets processed, ONLY after the journal has been set-up.
> Thus, "gio.File.monitor_file" has been used as the signalling mechanism.
>
> As rightly pointed out by Bernie and Sascha, gio-file-monitor might not
> be the best signalling/synchronizing mechaism here. I tried to use threading.Event()
> objects, but it needed to spawn another thread (note that all operations
> happen here in the context of the main-thread, even for "gobject.idle_add()"
> operations.
>
>
> CHANGELOG:
> ---------
>
> Changes of version-3 over version-2 :
> -------------------------------------
> a. Review changes as per Bernie and Sascha.
>
>
> Changes of version-2 over version-1 :
> -------------------------------------
> a. Reverted to the previous-behaviour, wherein the notification-message-icon
>   is shown at the end of all activity-icons (Thanks Anish and Estaban).
>   Of course, this included the fix of the issue :)
>
>
>  bin/sugar-session                  |   22 +++++++++++++++++++++-
>  src/jarabe/frame/activitiestray.py |   18 ++++++++++++++++++
>  2 files changed, 39 insertions(+), 1 deletions(-)
>
> diff --git a/bin/sugar-session b/bin/sugar-session
> index 40c9db7..1b28d4f 100755
> --- a/bin/sugar-session
> +++ b/bin/sugar-session
> @@ -21,6 +21,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()
> @@ -35,6 +36,9 @@ import gobject
>  import dbus.glib
>  import wnck
>
> +MONITORS = []
> +MONITOR_ACTION_TAKEN = False
> +
>  try:
>     import xklavier
>  except ImportError:
> @@ -181,15 +185,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)
> diff --git a/src/jarabe/frame/activitiestray.py b/src/jarabe/frame/activitiestray.py
> index 2b8b7c6..1c8e285 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.
> +        # Broadcast the signal-of-its-creation.
> +        if group is None:
> +            self._signal_addition_of_journal_activity()
> +
> +    def _signal_addition_of_journal_activity(self):
> +        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
>
> _______________________________________________
> Dextrose mailing list
> Dextrose at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/dextrose



-- 
Anish | anish at sugarlabs.org


More information about the Dextrose mailing list