Merge branch 'master' of git.sugarlabs.org:sugar-toolkit-gtk3/sugar-toolkit-gtk3

This commit is contained in:
Pootle daemon 2012-10-06 00:32:36 -04:00
commit 5b1c17d7ce
4 changed files with 90 additions and 6 deletions

View File

@ -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]) AC_PREREQ([2.59])

View File

@ -327,6 +327,13 @@ class Activity(Window, Gtk.Container):
if 'share-scope' in self._jobject.metadata: if 'share-scope' in self._jobject.metadata:
share_scope = self._jobject.metadata['share-scope'] 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.shared_activity = None
self._join_id = None self._join_id = None
@ -379,6 +386,7 @@ class Activity(Window, Gtk.Container):
jobject.metadata['preview'] = '' jobject.metadata['preview'] = ''
jobject.metadata['share-scope'] = SCOPE_PRIVATE jobject.metadata['share-scope'] = SCOPE_PRIVATE
jobject.metadata['icon-color'] = icon_color jobject.metadata['icon-color'] = icon_color
jobject.metadata['launch-times'] = str(int(time.time()))
jobject.file_path = '' jobject.file_path = ''
# FIXME: We should be able to get an ID synchronously from the DS, # FIXME: We should be able to get an ID synchronously from the DS,

View File

@ -29,6 +29,10 @@
typedef struct _SugarSwipeControllerPriv SugarSwipeControllerPriv; typedef struct _SugarSwipeControllerPriv SugarSwipeControllerPriv;
typedef struct _SugarEventData SugarEventData; typedef struct _SugarEventData SugarEventData;
enum {
PROP_DIRECTIONS = 1
};
enum { enum {
SWIPE_ENDED, SWIPE_ENDED,
LAST_SIGNAL LAST_SIGNAL
@ -48,6 +52,7 @@ struct _SugarSwipeControllerPriv
GArray *event_data; GArray *event_data;
guint swiping : 1; guint swiping : 1;
guint swiped : 1; guint swiped : 1;
guint directions : 4;
}; };
static guint signals[LAST_SIGNAL] = { 0 }; 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)); 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 static void
sugar_swipe_controller_finalize (GObject *object) sugar_swipe_controller_finalize (GObject *object)
{ {
@ -172,6 +213,7 @@ _sugar_swipe_controller_get_event_direction (SugarSwipeController *controller,
{ {
SugarSwipeControllerPriv *priv; SugarSwipeControllerPriv *priv;
SugarEventData *last, *check; SugarEventData *last, *check;
SugarSwipeDirection dir;
gint i; gint i;
priv = controller->_priv; priv = controller->_priv;
@ -190,7 +232,17 @@ _sugar_swipe_controller_get_event_direction (SugarSwipeController *controller,
break; 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 static void
@ -201,12 +253,16 @@ _sugar_swipe_controller_check_emit (SugarSwipeController *controller)
priv = controller->_priv; priv = controller->_priv;
if (!priv->swiping)
return;
if (_sugar_swipe_controller_get_event_direction (controller, &direction)) if (_sugar_swipe_controller_get_event_direction (controller, &direction))
{ {
priv->swiped = TRUE; priv->swiped = TRUE;
g_signal_emit (controller, signals[SWIPE_ENDED], 0, direction); 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 static gboolean
@ -314,6 +370,8 @@ sugar_swipe_controller_class_init (SugarSwipeControllerClass *klass)
GObjectClass *object_class; GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass); 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; object_class->finalize = sugar_swipe_controller_finalize;
controller_class = SUGAR_EVENT_CONTROLLER_CLASS (klass); 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->get_state = sugar_swipe_controller_get_state;
controller_class->reset = sugar_swipe_controller_reset; 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] = signals[SWIPE_ENDED] =
g_signal_new ("swipe-ended", g_signal_new ("swipe-ended",
SUGAR_TYPE_SWIPE_CONTROLLER, SUGAR_TYPE_SWIPE_CONTROLLER,
@ -335,7 +402,9 @@ sugar_swipe_controller_class_init (SugarSwipeControllerClass *klass)
} }
SugarEventController * 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);
} }

View File

@ -48,6 +48,13 @@ typedef enum {
SUGAR_SWIPE_DIRECTION_DOWN SUGAR_SWIPE_DIRECTION_DOWN
} SugarSwipeDirection; } 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 struct _SugarSwipeController
{ {
SugarEventController parent_instance; SugarEventController parent_instance;
@ -63,7 +70,7 @@ struct _SugarSwipeControllerClass
}; };
GType sugar_swipe_controller_get_type (void) G_GNUC_CONST; 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 G_END_DECLS