From 478b31a49e67fdd7ffa4d10748be101f3362e68e Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sat, 22 Sep 2007 03:37:31 +0200 Subject: [PATCH] Default order for activities in the frame. --- data/Makefile.am | 5 ++-- data/activities.defaults | 18 ++++++++++++++ shell/view/frame/activitiestray.py | 38 +++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 data/activities.defaults diff --git a/data/Makefile.am b/data/Makefile.am index 1fc8051f..887ed4ad 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -7,8 +7,9 @@ sugar-xo.gtkrc: gtkrc.em $(top_builddir)/data/sugar-xo.gtkrc sugardir = $(pkgdatadir)/data -sugar_DATA = \ - mime.defaults \ +sugar_DATA = \ + activities.defaults \ + mime.defaults \ $(GTKRC_FILES) GTKRC_FILES = \ diff --git a/data/activities.defaults b/data/activities.defaults new file mode 100644 index 00000000..7e937c64 --- /dev/null +++ b/data/activities.defaults @@ -0,0 +1,18 @@ +# Ordered list of the activities displayed in the frame + +org.laptop.Chat +org.laptop.WebActivity +org.laptop.AbiWordActivity +org.laptop.RecordActivity +org.laptop.Oficina +org.laptop.TamTamJam +org.vpri.EtoysActivity +org.laptop.TurtleArtActivity +org.laptop.Pippy +org.laptop.Calculate +org.laptop.MeasureActivity +org.laptop.TamTamEdit +org.laptop.TamTamSynthLab +org.laptop.Memorize +org.laptop.BlockPartyActivity +org.laptop.Connect diff --git a/shell/view/frame/activitiestray.py b/shell/view/frame/activitiestray.py index 94c4ee94..e4bbffcb 100644 --- a/shell/view/frame/activitiestray.py +++ b/shell/view/frame/activitiestray.py @@ -23,6 +23,7 @@ from sugar.graphics.icon import Icon from sugar.graphics import style from sugar import profile from sugar import activity +from sugar import env from activitybutton import ActivityButton @@ -54,6 +55,7 @@ class ActivitiesTray(hippo.CanvasBox): self._shell_model = self._shell.get_model() self._invite_to_item = {} self._invites = self._shell_model.get_invites() + self._config = self._load_config() self._tray = HTray() self.append(hippo.CanvasWidget(widget=self._tray), hippo.PACK_EXPAND) @@ -69,10 +71,40 @@ class ActivitiesTray(hippo.CanvasBox): self._invites.connect('invite-added', self._invite_added_cb) self._invites.connect('invite-removed', self._invite_removed_cb) + def _load_config(self): + config = [] + + f = open(env.get_data_path('activities.defaults'), 'r') + for line in f.readlines(): + line = line.strip() + if line and not line.startswith('#'): + config.append(line) + f.close() + + return config + def _get_activities_cb(self, activity_list): - for activity_info in activity_list: - if activity_info.show_launcher: - self.add_activity(activity_info) + known_activities = [] + unknown_activities = [] + name_to_activity = {} + + while activity_list: + info = activity_list.pop() + name_to_activity[info.service_name] = info + + if info.service_name in self._config: + known_activities.append(info) + else: + unknown_activities.append(info) + + sorted_activities = [] + for name in self._config: + if name in name_to_activity: + sorted_activities.append(name_to_activity[name]) + + for info in sorted_activities + unknown_activities: + if info.show_launcher: + self.add_activity(info) def _activity_clicked_cb(self, icon): self._shell.start_activity(icon.get_bundle_id())