diff options
author | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-10-06 04:32:36 (GMT) |
---|---|---|
committer | Pootle daemon <pootle@pootle.sugarlabs.org> | 2012-10-06 04:32:36 (GMT) |
commit | 5b1c17d7ceaac2d520d4e5afa12c77ffee23c24b (patch) | |
tree | 8a03b270ed84488d859f5b0e1c80f829e351ce19 | |
parent | 6346aab450c684b52c01e25fc9ee95e00eaea996 (diff) | |
parent | 31d6e6dd1eed4732d277cc0e0514f4cff7d73e32 (diff) |
Merge branch 'master' of git.sugarlabs.org:sugar-toolkit-gtk3/sugar-toolkit-gtk3
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/sugar3/activity/activity.py | 8 | ||||
-rw-r--r-- | src/sugar3/event-controller/sugar-swipe-controller.c | 77 | ||||
-rw-r--r-- | src/sugar3/event-controller/sugar-swipe-controller.h | 9 |
4 files changed, 90 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index 6712f5d..953c3c4 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]) diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py index c896caf..3325f47 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, diff --git a/src/sugar3/event-controller/sugar-swipe-controller.c b/src/sugar3/event-controller/sugar-swipe-controller.c index 25456a0..2b57861 100644 --- a/src/sugar3/event-controller/sugar-swipe-controller.c +++ b/src/sugar3/event-controller/sugar-swipe-controller.c @@ -30,6 +30,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 }; @@ -68,6 +73,42 @@ sugar_swipe_controller_init (SugarSwipeController *controller) } 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) { G_OBJECT_CLASS (sugar_swipe_controller_parent_class)->finalize (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 c7b67cf..2e69474 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 |