mousetweaks r124 - in trunk: . src
- From: gerdk svn gnome org
- To: svn-commits-list gnome org
- Subject: mousetweaks r124 - in trunk: . src
- Date: Fri, 28 Mar 2008 09:54:37 +0000 (GMT)
Author: gerdk
Date: Fri Mar 28 09:54:37 2008
New Revision: 124
URL: http://svn.gnome.org/viewvc/mousetweaks?rev=124&view=rev
Log:
2008-03-28 Gerd Kohlberger <gerdk svn gnome org>
* mt-timer.c: Add new 'tick' signal. Remove properties.
* mt-timer.h: Clean up.
* mt-main.c: Use changed function name.
Modified:
trunk/ChangeLog
trunk/src/mt-main.c
trunk/src/mt-timer.c
trunk/src/mt-timer.h
Modified: trunk/src/mt-main.c
==============================================================================
--- trunk/src/mt-main.c (original)
+++ trunk/src/mt-main.c Fri Mar 28 09:54:37 2008
@@ -341,9 +341,9 @@
mt->style = gconf_client_get_int (mt->client, OPT_STYLE, NULL);
val = gconf_client_get_float (mt->client, OPT_DELAY_T, NULL);
- mt_timer_set_target_time (mt->delay_timer, val);
+ mt_timer_set_target (mt->delay_timer, val);
val = gconf_client_get_float (mt->client, OPT_DWELL_T, NULL);
- mt_timer_set_target_time (mt->dwell_timer, val);
+ mt_timer_set_target (mt->dwell_timer, val);
mt->dwell_dirs[DWELL_CLICK_TYPE_SINGLE] =
gconf_client_get_int (mt->client, OPT_G_SINGLE, NULL);
Modified: trunk/src/mt-timer.c
==============================================================================
--- trunk/src/mt-timer.c (original)
+++ trunk/src/mt-timer.c Fri Mar 28 09:54:37 2008
@@ -33,11 +33,7 @@
};
enum {
- PROP_0,
- PROP_TARGET
-};
-
-enum {
+ TICK,
FINISHED,
LAST_SIGNAL
};
@@ -46,39 +42,34 @@
G_DEFINE_TYPE (MtTimer, mt_timer, G_TYPE_OBJECT)
-static void mt_timer_dispose (GObject *object);
-static void mt_timer_finalize (GObject *object);
-static void mt_timer_set_property (GObject *object,
- guint property,
- const GValue *value,
- GParamSpec *pspec);
-static void mt_timer_get_property (GObject *object,
- guint property,
- GValue *value,
- GParamSpec *pspec);
+static void mt_timer_dispose (GObject *object);
+static void mt_timer_finalize (GObject *object);
static void
mt_timer_class_init (MtTimerClass *klass)
{
- GParamSpec *pspec;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->dispose = mt_timer_dispose;
- gobject_class->finalize = mt_timer_finalize;
- gobject_class->set_property = mt_timer_set_property;
- gobject_class->get_property = mt_timer_get_property;
-
- pspec = g_param_spec_double ("target", "Target", "Target time to check for",
- 0.5, 3.0, 1.2, G_PARAM_READWRITE);
- g_object_class_install_property (gobject_class, PROP_TARGET, pspec);
-
- signals[FINISHED] = g_signal_new (g_intern_static_string ("finished"),
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MtTimerClass, finished),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ gobject_class->dispose = mt_timer_dispose;
+ gobject_class->finalize = mt_timer_finalize;
+
+ signals[TICK] =
+ g_signal_new (g_intern_static_string ("tick"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (MtTimerClass, tick),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__DOUBLE,
+ G_TYPE_NONE, 1, G_TYPE_DOUBLE);
+
+ signals[FINISHED] =
+ g_signal_new (g_intern_static_string ("finished"),
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (MtTimerClass, finished),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
g_type_class_add_private (klass, sizeof (MtTimerPrivate));
}
@@ -86,7 +77,7 @@
static void
mt_timer_init (MtTimer *timer)
{
- MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE(timer);
+ MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE (timer);
priv->timer = NULL;
priv->tid = 0;
@@ -97,8 +88,8 @@
static void
mt_timer_dispose (GObject *object)
{
- MtTimer *timer = MT_TIMER(object);
- MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE(timer);
+ MtTimer *timer = MT_TIMER (object);
+ MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE (timer);
if (mt_timer_is_running (timer)) {
g_timer_stop (priv->timer);
@@ -116,57 +107,21 @@
static void
mt_timer_finalize (GObject *object)
{
- MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE(object);
+ MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE (object);
g_timer_destroy (priv->timer);
- priv->timer = NULL;
G_OBJECT_CLASS (mt_timer_parent_class)->finalize (object);
}
-static void
-mt_timer_set_property (GObject *object,
- guint property,
- const GValue *value,
- GParamSpec *pspec)
-{
- MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE(object);
-
- switch (property) {
- case PROP_TARGET:
- priv->target = g_value_get_double (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property, pspec);
- break;
- }
-}
-
-static void
-mt_timer_get_property (GObject *object,
- guint property,
- GValue *value,
- GParamSpec *pspec)
-{
- MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE(object);
-
- switch (property) {
- case PROP_TARGET:
- g_value_set_double (value, priv->target);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property, pspec);
- break;
- }
-}
-
static gboolean
mt_timer_check_time (gpointer data)
{
MtTimer *timer = (MtTimer *) data;
- MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE(timer);
+ MtTimerPrivate *priv = MT_TIMER_GET_PRIVATE (timer);
priv->elapsed = g_timer_elapsed (priv->timer, NULL);
+ g_signal_emit (timer, signals[TICK], 0, priv->elapsed);
if (priv->elapsed >= priv->target) {
priv->tid = 0;
@@ -187,7 +142,7 @@
MtTimerPrivate *priv;
timer = g_object_new (MT_TYPE_TIMER, NULL);
- priv = MT_TIMER_GET_PRIVATE(timer);
+ priv = MT_TIMER_GET_PRIVATE (timer);
priv->timer = g_timer_new ();
g_timer_stop (priv->timer);
@@ -200,9 +155,9 @@
{
MtTimerPrivate *priv;
- g_return_if_fail (MT_IS_TIMER(timer));
+ g_return_if_fail (MT_IS_TIMER (timer));
- priv = MT_TIMER_GET_PRIVATE(timer);
+ priv = MT_TIMER_GET_PRIVATE (timer);
g_timer_start (priv->timer);
if (priv->tid == 0)
@@ -214,9 +169,9 @@
{
MtTimerPrivate *priv;
- g_return_if_fail (MT_IS_TIMER(timer));
+ g_return_if_fail (MT_IS_TIMER (timer));
- priv = MT_TIMER_GET_PRIVATE(timer);
+ priv = MT_TIMER_GET_PRIVATE (timer);
g_timer_stop (priv->timer);
if (priv->tid != 0) {
@@ -228,30 +183,36 @@
gboolean
mt_timer_is_running (MtTimer *timer)
{
- MtTimerPrivate *priv;
+ g_return_val_if_fail (MT_IS_TIMER (timer), FALSE);
- g_return_val_if_fail (MT_IS_TIMER(timer), FALSE);
+ return (MT_TIMER_GET_PRIVATE (timer)->tid != 0);
+}
- priv = MT_TIMER_GET_PRIVATE(timer);
+gdouble
+mt_timer_elapsed (MtTimer *timer)
+{
+ g_return_val_if_fail (MT_IS_TIMER (timer), 0.0);
- return (priv->tid != 0);
+ return MT_TIMER_GET_PRIVATE (timer)->elapsed;
}
gdouble
-mt_timer_elapsed (MtTimer *timer)
+mt_timer_get_target (MtTimer *timer)
{
- g_return_val_if_fail (MT_IS_TIMER(timer), 0.0);
+ MtTimerPrivate *priv;
+
+ g_return_val_if_fail (MT_IS_TIMER (timer), 0.0);
- return MT_TIMER_GET_PRIVATE(timer)->elapsed;
+ return MT_TIMER_GET_PRIVATE (timer)->target;
}
void
-mt_timer_set_target_time (MtTimer *timer, gdouble time)
+mt_timer_set_target (MtTimer *timer, gdouble time)
{
MtTimerPrivate *priv;
- g_return_if_fail (MT_IS_TIMER(timer));
+ g_return_if_fail (MT_IS_TIMER (timer));
+ g_return_if_fail (time >= 0.5);
- priv = MT_TIMER_GET_PRIVATE(timer);
- g_object_set (timer, "target", time, NULL);
+ MT_TIMER_GET_PRIVATE (timer)->target = time;
}
Modified: trunk/src/mt-timer.h
==============================================================================
--- trunk/src/mt-timer.h (original)
+++ trunk/src/mt-timer.h Fri Mar 28 09:54:37 2008
@@ -41,18 +41,21 @@
struct _MtTimerClass {
GObjectClass parent;
+ void (*tick) (MtTimer *timer,
+ gdouble time);
void (*finished) (MtTimer *timer);
};
-GType mt_timer_get_type (void) G_GNUC_CONST;
+GType mt_timer_get_type (void) G_GNUC_CONST;
-MtTimer * mt_timer_new (void);
-void mt_timer_start (MtTimer *timer);
-void mt_timer_stop (MtTimer *timer);
-gboolean mt_timer_is_running (MtTimer *timer);
-gdouble mt_timer_elapsed (MtTimer *timer);
-void mt_timer_set_target_time (MtTimer *timer,
- gdouble time);
+MtTimer * mt_timer_new (void);
+void mt_timer_start (MtTimer *timer);
+void mt_timer_stop (MtTimer *timer);
+gboolean mt_timer_is_running (MtTimer *timer);
+gdouble mt_timer_elapsed (MtTimer *timer);
+gdouble mt_timer_get_target (MtTimer *timer);
+void mt_timer_set_target (MtTimer *timer,
+ gdouble time);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]