From 2a15fbc0f2269b1d61e5fa8ea723cb4848a8ee74 Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Thu, 4 Oct 2012 09:38:45 -0300 Subject: [PATCH 1/3] Add in the metadata info about every startup time Signed-off-by: Walter Bender Tested-by: Gonzalo Odiard Acked-by: Simon Schampijer --- src/sugar3/activity/activity.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py index c896caff..3325f476 100644 --- a/src/sugar3/activity/activity.py +++ b/src/sugar3/activity/activity.py @@ -327,6 +327,13 @@ class Activity(Window, Gtk.Container): if 'share-scope' in self._jobject.metadata: share_scope = self._jobject.metadata['share-scope'] + if 'launch-times' in self._jobject.metadata: + self._jobject.metadata['launch-times'] += ', %d' % \ + int(time.time()) + else: + self._jobject.metadata['launch-times'] = \ + str(int(time.time())) + self.shared_activity = None self._join_id = None @@ -379,6 +386,7 @@ class Activity(Window, Gtk.Container): jobject.metadata['preview'] = '' jobject.metadata['share-scope'] = SCOPE_PRIVATE jobject.metadata['icon-color'] = icon_color + jobject.metadata['launch-times'] = str(int(time.time())) jobject.file_path = '' # FIXME: We should be able to get an ID synchronously from the DS, From fe0022cd8f6a8fb94d379be287761cc3a6206086 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 5 Oct 2012 14:31:28 +0200 Subject: [PATCH 2/3] swipe: Allow setting allowed directions as a set of flags The allowed swipe directions can be specified now at construct time, so the swipe-ended signal is only emitted for those directions. Signed-off-by: Carlos Garnacho Acked-by: Simon Schampijer --- .../event-controller/sugar-swipe-controller.c | 77 ++++++++++++++++++- .../event-controller/sugar-swipe-controller.h | 9 ++- 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/src/sugar3/event-controller/sugar-swipe-controller.c b/src/sugar3/event-controller/sugar-swipe-controller.c index 25456a0b..2b578619 100644 --- a/src/sugar3/event-controller/sugar-swipe-controller.c +++ b/src/sugar3/event-controller/sugar-swipe-controller.c @@ -29,6 +29,10 @@ typedef struct _SugarSwipeControllerPriv SugarSwipeControllerPriv; typedef struct _SugarEventData SugarEventData; +enum { + PROP_DIRECTIONS = 1 +}; + enum { SWIPE_ENDED, LAST_SIGNAL @@ -48,6 +52,7 @@ struct _SugarSwipeControllerPriv GArray *event_data; guint swiping : 1; guint swiped : 1; + guint directions : 4; }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -67,6 +72,42 @@ sugar_swipe_controller_init (SugarSwipeController *controller) priv->event_data = g_array_new (FALSE, FALSE, sizeof (SugarEventData)); } +static void +sugar_swipe_controller_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + SugarSwipeControllerPriv *priv = SUGAR_SWIPE_CONTROLLER (object)->_priv; + + switch (prop_id) + { + case PROP_DIRECTIONS: + g_value_set_flags (value, priv->directions); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +sugar_swipe_controller_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + SugarSwipeControllerPriv *priv = SUGAR_SWIPE_CONTROLLER (object)->_priv; + + switch (prop_id) + { + case PROP_DIRECTIONS: + priv->directions = g_value_get_flags (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + static void sugar_swipe_controller_finalize (GObject *object) { @@ -172,6 +213,7 @@ _sugar_swipe_controller_get_event_direction (SugarSwipeController *controller, { SugarSwipeControllerPriv *priv; SugarEventData *last, *check; + SugarSwipeDirection dir; gint i; priv = controller->_priv; @@ -190,7 +232,17 @@ _sugar_swipe_controller_get_event_direction (SugarSwipeController *controller, break; } - return _sugar_swipe_controller_get_direction (check, last, direction); + if (!_sugar_swipe_controller_get_direction (check, last, &dir)) + return FALSE; + + /* Check whether the direction is allowed */ + if ((priv->directions & (1 << dir)) == 0) + return FALSE; + + if (direction) + *direction = dir; + + return TRUE; } static void @@ -201,12 +253,16 @@ _sugar_swipe_controller_check_emit (SugarSwipeController *controller) priv = controller->_priv; + if (!priv->swiping) + return; + if (_sugar_swipe_controller_get_event_direction (controller, &direction)) { priv->swiped = TRUE; g_signal_emit (controller, signals[SWIPE_ENDED], 0, direction); - g_signal_emit_by_name (G_OBJECT (controller), "ended"); } + + g_signal_emit_by_name (G_OBJECT (controller), "ended"); } static gboolean @@ -314,6 +370,8 @@ sugar_swipe_controller_class_init (SugarSwipeControllerClass *klass) GObjectClass *object_class; object_class = G_OBJECT_CLASS (klass); + object_class->get_property = sugar_swipe_controller_get_property; + object_class->set_property = sugar_swipe_controller_set_property; object_class->finalize = sugar_swipe_controller_finalize; controller_class = SUGAR_EVENT_CONTROLLER_CLASS (klass); @@ -321,6 +379,15 @@ sugar_swipe_controller_class_init (SugarSwipeControllerClass *klass) controller_class->get_state = sugar_swipe_controller_get_state; controller_class->reset = sugar_swipe_controller_reset; + g_object_class_install_property (object_class, + PROP_DIRECTIONS, + g_param_spec_flags ("directions", + "Directions", + "Allowed swipe directions", + SUGAR_TYPE_SWIPE_DIRECTION_FLAGS, 0, + G_PARAM_READABLE | + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY)); signals[SWIPE_ENDED] = g_signal_new ("swipe-ended", SUGAR_TYPE_SWIPE_CONTROLLER, @@ -335,7 +402,9 @@ sugar_swipe_controller_class_init (SugarSwipeControllerClass *klass) } SugarEventController * -sugar_swipe_controller_new (void) +sugar_swipe_controller_new (SugarSwipeDirectionFlags directions) { - return g_object_new (SUGAR_TYPE_SWIPE_CONTROLLER, NULL); + return g_object_new (SUGAR_TYPE_SWIPE_CONTROLLER, + "directions", directions, + NULL); } diff --git a/src/sugar3/event-controller/sugar-swipe-controller.h b/src/sugar3/event-controller/sugar-swipe-controller.h index c7b67cfd..2e69474d 100644 --- a/src/sugar3/event-controller/sugar-swipe-controller.h +++ b/src/sugar3/event-controller/sugar-swipe-controller.h @@ -48,6 +48,13 @@ typedef enum { SUGAR_SWIPE_DIRECTION_DOWN } SugarSwipeDirection; +typedef enum { + SUGAR_SWIPE_DIRECTION_FLAG_LEFT = 1 << SUGAR_SWIPE_DIRECTION_LEFT, + SUGAR_SWIPE_DIRECTION_FLAG_RIGHT = 1 << SUGAR_SWIPE_DIRECTION_RIGHT, + SUGAR_SWIPE_DIRECTION_FLAG_UP = 1 << SUGAR_SWIPE_DIRECTION_UP, + SUGAR_SWIPE_DIRECTION_FLAG_DOWN = 1 << SUGAR_SWIPE_DIRECTION_DOWN, +} SugarSwipeDirectionFlags; + struct _SugarSwipeController { SugarEventController parent_instance; @@ -63,7 +70,7 @@ struct _SugarSwipeControllerClass }; GType sugar_swipe_controller_get_type (void) G_GNUC_CONST; -SugarEventController * sugar_swipe_controller_new (void); +SugarEventController * sugar_swipe_controller_new (SugarSwipeDirectionFlags directions); G_END_DECLS From 31d6e6dd1eed4732d277cc0e0514f4cff7d73e32 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Fri, 5 Oct 2012 20:43:52 +0200 Subject: [PATCH 3/3] Release 0.97.5 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6712f5dd..953c3c4f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([sugar-toolkit-gtk3],[0.97.4],[],[sugar-toolkit-gtk3]) +AC_INIT([sugar-toolkit-gtk3],[0.97.5],[],[sugar-toolkit-gtk3]) AC_PREREQ([2.59])