gdm r6095 - in trunk: . common gui/simple-greeter
- From: halfline svn gnome org
- To: svn-commits-list gnome org
- Subject: gdm r6095 - in trunk: . common gui/simple-greeter
- Date: Thu, 3 Apr 2008 21:54:23 +0100 (BST)
Author: halfline
Date: Thu Apr 3 21:54:23 2008
New Revision: 6095
URL: http://svn.gnome.org/viewvc/gdm?rev=6095&view=rev
Log:
2008-04-03 Ray Strode <rstrode redhat com>
* gui/simple-greeter/gdm-timer.[ch]:
new files to make animations easier
* gui/simple-greeter/gdm-chooser-widget.c
(struct GdmChooserWidgetPrivate),
(on_shrink_animation_tick), (on_grow_animation_tick),
(on_shrink_animation_stop), (on_grow_animation_stop),
(start_shrink_animation), (gdm_chooser_widget_finalize):
* common/gdm-marshal.list:
Switch chooser over to use timer
Added:
trunk/gui/simple-greeter/gdm-timer.c
trunk/gui/simple-greeter/gdm-timer.h
Modified:
trunk/ChangeLog
trunk/common/gdm-marshal.list
trunk/gui/simple-greeter/Makefile.am
trunk/gui/simple-greeter/gdm-chooser-widget.c
Modified: trunk/common/gdm-marshal.list
==============================================================================
--- trunk/common/gdm-marshal.list (original)
+++ trunk/common/gdm-marshal.list Thu Apr 3 21:54:23 2008
@@ -4,3 +4,4 @@
VOID:STRING,STRING
VOID:UINT,UINT
VOID:STRING,INT
+VOID:DOUBLE
Modified: trunk/gui/simple-greeter/Makefile.am
==============================================================================
--- trunk/gui/simple-greeter/Makefile.am (original)
+++ trunk/gui/simple-greeter/Makefile.am Thu Apr 3 21:54:23 2008
@@ -68,6 +68,8 @@
test_greeter_login_window_SOURCES = \
test-greeter-login-window.c \
+ gdm-timer.h \
+ gdm-timer.c \
gdm-greeter-login-window.h \
gdm-greeter-login-window.c \
gdm-chooser-widget.h \
@@ -105,6 +107,8 @@
gdm-languages.c \
gdm-cell-renderer-timer.h \
gdm-cell-renderer-timer.c \
+ gdm-timer.h \
+ gdm-timer.c \
gdm-chooser-widget.h \
gdm-chooser-widget.c \
gdm-language-chooser-widget.h \
@@ -145,6 +149,8 @@
test-language-chooser.c \
gdm-cell-renderer-timer.h \
gdm-cell-renderer-timer.c \
+ gdm-timer.h \
+ gdm-timer.c \
gdm-chooser-widget.h \
gdm-chooser-widget.c \
gdm-languages.h \
@@ -173,6 +179,8 @@
test_user_chooser_SOURCES = \
test-user-chooser.c \
+ gdm-timer.h \
+ gdm-timer.c \
gdm-cell-renderer-timer.h \
gdm-cell-renderer-timer.c \
gdm-chooser-widget.h \
@@ -217,6 +225,8 @@
gdm_simple_greeter_SOURCES = \
greeter-main.c \
+ gdm-timer.h \
+ gdm-timer.c \
gdm-cell-renderer-timer.h \
gdm-cell-renderer-timer.c \
gdm-chooser-widget.h \
Modified: trunk/gui/simple-greeter/gdm-chooser-widget.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-chooser-widget.c (original)
+++ trunk/gui/simple-greeter/gdm-chooser-widget.c Thu Apr 3 21:54:23 2008
@@ -36,6 +36,7 @@
#include "gdm-chooser-widget.h"
#include "gdm-cell-renderer-timer.h"
+#include "gdm-timer.h"
#define GDM_CHOOSER_WIDGET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_CHOOSER_WIDGET, GdmChooserWidgetPrivate))
@@ -84,8 +85,10 @@
gint number_of_rows_with_images;
gint number_of_active_timers;
+ GdmTimer *grow_animation_timer;
+ GdmTimer *shrink_animation_timer;
+
guint update_idle_id;
- guint resize_animation_timeout_id;
guint timer_animation_timeout_id;
guint32 should_hide_inactive_items : 1;
@@ -456,6 +459,31 @@
return is_done;
}
+static int
+get_number_of_on_screen_rows (GdmChooserWidget *widget)
+{
+ GtkTreePath *start_path;
+ GtkTreePath *end_path;
+ int *start_index;
+ int *end_index;
+ int number_of_rows;
+
+ if (!gtk_tree_view_get_visible_range (GTK_TREE_VIEW (widget->priv->items_view),
+ &start_path, &end_path)) {
+ return 0;
+ }
+
+ start_index = gtk_tree_path_get_indices (start_path);
+ end_index = gtk_tree_path_get_indices (end_path);
+
+ number_of_rows = *end_index - *start_index;
+
+ gtk_tree_path_free (start_path);
+ gtk_tree_path_free (end_path);
+
+ return number_of_rows;
+}
+
static gboolean
run_grow_animation (GdmChooserWidget *widget,
int number_of_iterations)
@@ -501,33 +529,84 @@
return is_done;
}
-static gboolean
-on_shrink_animation_timeout (GdmChooserWidget *widget)
+static void
+on_shrink_animation_tick (GdmChooserWidget *widget,
+ double progress)
{
- if (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_SHRINKING) {
- return run_shrink_animation (widget, 1) != TRUE;
+ int number_of_iterations;
+ int number_of_visible_rows;
+ int number_of_rows;
+ int number_of_rows_to_be_gone;
+ int number_of_rows_gone;
+
+ if (widget->priv->state != GDM_CHOOSER_WIDGET_STATE_SHRINKING) {
+ return;
}
- return FALSE;
-}
+ number_of_visible_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->model_sorter), NULL);
-static gboolean
-on_grow_animation_timeout (GdmChooserWidget *widget)
-{
- if (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_GROWING) {
- return run_grow_animation (widget, 1) != TRUE;
+ if (number_of_visible_rows <= 1) {
+ gdm_timer_stop (widget->priv->shrink_animation_timer);
+ return;
}
- return FALSE;
+ number_of_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->list_store), NULL);
+
+ number_of_rows_to_be_gone = progress * number_of_rows;
+ number_of_rows_gone = number_of_rows - number_of_visible_rows;
+
+ number_of_iterations = number_of_rows_to_be_gone - number_of_rows_gone;
+
+ if (number_of_iterations <= 0) {
+ return;
+ }
+
+ if (run_shrink_animation (widget, number_of_iterations)) {
+ gdm_timer_stop (widget->priv->shrink_animation_timer);
+ }
}
static void
-on_shrink_animation_done (GdmChooserWidget *widget)
+on_grow_animation_tick (GdmChooserWidget *widget,
+ double progress)
{
- if (widget->priv->resize_animation_timeout_id == 0) {
+ int number_of_iterations;
+ int number_of_visible_rows;
+ int number_of_rows;
+ int number_of_rows_wanted;
+
+ if (widget->priv->state != GDM_CHOOSER_WIDGET_STATE_GROWING) {
+ return;
+ }
+
+ number_of_visible_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->model_sorter), NULL);
+ number_of_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->list_store), NULL);
+
+ if (number_of_visible_rows == number_of_rows) {
+ gdm_timer_stop (widget->priv->shrink_animation_timer);
+ return;
+ }
+
+ number_of_rows_wanted = progress * number_of_rows;
+
+ number_of_iterations = number_of_rows_wanted - number_of_visible_rows;
+
+ if (number_of_iterations <= 0) {
return;
}
+ if (run_grow_animation (widget, number_of_iterations)) {
+ gdm_timer_stop (widget->priv->shrink_animation_timer);
+ }
+}
+
+static void
+on_shrink_animation_stop (GdmChooserWidget *widget)
+{
+
+ g_assert (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_SHRINKING);
+ widget->priv->state = GDM_CHOOSER_WIDGET_STATE_SHRUNK;
+
if (widget->priv->top_edge_row != NULL) {
gtk_tree_row_reference_free (widget->priv->top_edge_row);
widget->priv->top_edge_row = NULL;
@@ -538,54 +617,26 @@
widget->priv->bottom_edge_row = NULL;
}
- widget->priv->resize_animation_timeout_id = 0;
- gtk_widget_set_sensitive (GTK_WIDGET (widget), TRUE);
-
if (widget->priv->emit_activated_after_resize_animation) {
g_signal_emit (widget, signals[ACTIVATED], 0);
widget->priv->emit_activated_after_resize_animation = FALSE;
}
+
+ gtk_widget_set_sensitive (GTK_WIDGET (widget), TRUE);
}
static void
-on_grow_animation_done (GdmChooserWidget *widget)
+on_grow_animation_stop (GdmChooserWidget *widget)
{
- if (widget->priv->resize_animation_timeout_id == 0) {
- return;
- }
-
- widget->priv->resize_animation_timeout_id = 0;
- gtk_widget_set_sensitive (GTK_WIDGET (widget), TRUE);
+ g_assert (widget->priv->state == GDM_CHOOSER_WIDGET_STATE_GROWING);
+ widget->priv->state = GDM_CHOOSER_WIDGET_STATE_GROWN;
if (widget->priv->emit_activated_after_resize_animation) {
g_signal_emit (widget, signals[ACTIVATED], 0);
widget->priv->emit_activated_after_resize_animation = FALSE;
}
-}
-static int
-get_number_of_on_screen_rows (GdmChooserWidget *widget)
-{
- GtkTreePath *start_path;
- GtkTreePath *end_path;
- int *start_index;
- int *end_index;
- int number_of_rows;
-
- if (!gtk_tree_view_get_visible_range (GTK_TREE_VIEW (widget->priv->items_view),
- &start_path, &end_path)) {
- return 0;
- }
-
- start_index = gtk_tree_path_get_indices (start_path);
- end_index = gtk_tree_path_get_indices (end_path);
-
- number_of_rows = *end_index - *start_index;
-
- gtk_tree_path_free (start_path);
- gtk_tree_path_free (end_path);
-
- return number_of_rows;
+ gtk_widget_set_sensitive (GTK_WIDGET (widget), TRUE);
}
static void
@@ -597,16 +648,16 @@
int number_of_on_screen_rows;
int number_of_iterations;
- if (widget->priv->resize_animation_timeout_id != 0) {
- g_source_remove (widget->priv->resize_animation_timeout_id);
+ if (widget->priv->shrink_animation_timer != NULL &&
+ gdm_timer_is_started (widget->priv->shrink_animation_timer)) {
+ gdm_timer_stop (widget->priv->shrink_animation_timer);
}
number_of_visible_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->model_sorter), NULL);
number_of_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->list_store), NULL);
if (number_of_visible_rows <= 1) {
- widget->priv->state = GDM_CHOOSER_WIDGET_STATE_SHRUNK;
- on_shrink_animation_done (widget);
+ on_shrink_animation_stop (widget);
return;
}
@@ -620,51 +671,62 @@
widget->priv->bottom_edge_row = gtk_tree_row_reference_new (GTK_TREE_MODEL (widget->priv->model_sorter),
edge_path);
gtk_tree_path_free (edge_path);
-
g_assert (widget->priv->top_edge_row != NULL && widget->priv->bottom_edge_row != NULL);
+ gtk_widget_set_sensitive (GTK_WIDGET (widget), FALSE);
+
number_of_on_screen_rows = get_number_of_on_screen_rows (widget);
number_of_iterations = number_of_visible_rows - number_of_on_screen_rows;
number_of_iterations = MAX (0, number_of_iterations);
run_shrink_animation (widget, number_of_iterations);
- gtk_widget_set_sensitive (GTK_WIDGET (widget), FALSE);
+ if (widget->priv->shrink_animation_timer == NULL) {
+ widget->priv->shrink_animation_timer = gdm_timer_new ();
- widget->priv->resize_animation_timeout_id =
- g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
- 1000 / (4 * number_of_rows),
- (GSourceFunc) on_shrink_animation_timeout,
- widget, (GDestroyNotify) on_shrink_animation_done);
+ g_signal_connect_swapped (G_OBJECT (widget->priv->shrink_animation_timer),
+ "tick", G_CALLBACK (on_shrink_animation_tick),
+ widget);
+ g_signal_connect_swapped (G_OBJECT (widget->priv->shrink_animation_timer),
+ "stop", G_CALLBACK (on_shrink_animation_stop),
+ widget);
+ }
+
+ gdm_timer_start (widget->priv->shrink_animation_timer, 1.0);
}
static void
start_grow_animation (GdmChooserWidget *widget)
{
- GtkTreePath *edge_path;
int number_of_visible_rows;
int number_of_rows;
- if (widget->priv->resize_animation_timeout_id != 0) {
- g_source_remove (widget->priv->resize_animation_timeout_id);
+ if (widget->priv->grow_animation_timer != NULL &&
+ gdm_timer_is_started (widget->priv->grow_animation_timer)) {
+ gdm_timer_stop (widget->priv->grow_animation_timer);
}
number_of_visible_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->model_sorter), NULL);
number_of_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (widget->priv->list_store), NULL);
if (number_of_visible_rows >= number_of_rows) {
- widget->priv->state = GDM_CHOOSER_WIDGET_STATE_GROWN;
- on_grow_animation_done (widget);
+ on_grow_animation_stop (widget);
return;
}
gtk_widget_set_sensitive (GTK_WIDGET (widget), FALSE);
- widget->priv->resize_animation_timeout_id =
- g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
- 1000 / (4 * number_of_rows),
- (GSourceFunc) on_grow_animation_timeout,
- widget, (GDestroyNotify) on_grow_animation_done);
+ if (widget->priv->grow_animation_timer == NULL) {
+ widget->priv->grow_animation_timer = gdm_timer_new ();
+
+ g_signal_connect_swapped (G_OBJECT (widget->priv->grow_animation_timer),
+ "tick", G_CALLBACK (on_grow_animation_tick),
+ widget);
+ g_signal_connect_swapped (G_OBJECT (widget->priv->grow_animation_timer),
+ "stop", G_CALLBACK (on_grow_animation_stop),
+ widget);
+ }
+ gdm_timer_start (widget->priv->grow_animation_timer, 1.0);
}
static void
@@ -1797,6 +1859,16 @@
g_hash_table_destroy (widget->priv->rows_with_timers);
widget->priv->rows_with_timers = NULL;
+ if (widget->priv->shrink_animation_timer != NULL) {
+ g_object_unref (widget->priv->shrink_animation_timer);
+ widget->priv->shrink_animation_timer = NULL;
+ }
+
+ if (widget->priv->grow_animation_timer != NULL) {
+ g_object_unref (widget->priv->grow_animation_timer);
+ widget->priv->grow_animation_timer = NULL;
+ }
+
G_OBJECT_CLASS (gdm_chooser_widget_parent_class)->finalize (object);
}
Added: trunk/gui/simple-greeter/gdm-timer.c
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/gdm-timer.c Thu Apr 3 21:54:23 2008
@@ -0,0 +1,312 @@
+/*
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Written by: Ray Strode <rstrode redhat com>
+ */
+
+#include "config.h"
+#include "gdm-timer.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+
+#include "gdm-marshal.h"
+
+#define GDM_TIMER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_TIMER, GdmTimerPrivate))
+
+#ifndef GDM_TIMER_TICKS_PER_SECOND
+#define GDM_TIMER_TICKS_PER_SECOND 60
+#endif
+
+struct GdmTimerPrivate
+{
+ double start_time;
+ double duration;
+
+ guint tick_timeout_id;
+
+ guint is_started : 1;
+};
+
+enum {
+ PROP_0,
+ PROP_START_TIME,
+ PROP_DURATION,
+ PROP_IS_STARTED
+};
+
+enum {
+ TICK,
+ STOP,
+ NUMBER_OF_SIGNALS
+};
+
+static guint signals[NUMBER_OF_SIGNALS];
+
+static void gdm_timer_class_init (GdmTimerClass *klass);
+static void gdm_timer_init (GdmTimer *timer);
+static void gdm_timer_finalize (GObject *object);
+
+static void gdm_timer_queue_next_tick (GdmTimer *timer,
+ double when);
+
+G_DEFINE_TYPE (GdmTimer, gdm_timer, G_TYPE_OBJECT)
+
+static void
+gdm_timer_finalize (GObject *object)
+{
+ GdmTimer *timer;
+
+ timer = GDM_TIMER (object);
+
+ gdm_timer_stop (timer);
+
+ G_OBJECT_CLASS (gdm_timer_parent_class)->finalize (object);
+}
+
+static void
+gdm_timer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GdmTimer *timer;
+
+ timer = GDM_TIMER (object);
+
+ switch (prop_id) {
+ case PROP_START_TIME:
+ g_value_set_double (value, timer->priv->start_time);
+ break;
+ case PROP_DURATION:
+ g_value_set_double (value, timer->priv->duration);
+ break;
+ case PROP_IS_STARTED:
+ g_value_set_boolean (value, timer->priv->is_started);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gdm_timer_class_init (GdmTimerClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gdm_timer_finalize;
+ object_class->get_property = gdm_timer_get_property;
+
+ signals[TICK] = g_signal_new ("tick",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmTimerClass, tick),
+ NULL,
+ NULL,
+ gdm_marshal_VOID__DOUBLE,
+ G_TYPE_NONE,
+ 1, G_TYPE_DOUBLE);
+ signals[STOP] = g_signal_new ("stop",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdmTimerClass, stop),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_object_class_install_property (object_class,
+ PROP_DURATION,
+ g_param_spec_double ("duration",
+ _("Duration"),
+ _("Number of seconds until timer stops"),
+ 0.0, G_MAXDOUBLE, 0.0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_START_TIME,
+ g_param_spec_double ("start-time",
+ _("Start time"),
+ _("Time the timer was started"),
+ 0.0, G_MAXDOUBLE, 0.0,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
+ PROP_IS_STARTED,
+ g_param_spec_boolean ("is-started",
+ _("Is it Running?"),
+ _("Whether or not the timer "
+ "is currently ticking"),
+ FALSE, G_PARAM_READABLE));
+
+
+
+ g_type_class_add_private (klass, sizeof (GdmTimerPrivate));
+}
+
+static void
+gdm_timer_init (GdmTimer *timer)
+{
+ timer->priv = GDM_TIMER_GET_PRIVATE (timer);
+}
+
+GdmTimer *
+gdm_timer_new (void)
+{
+ GObject *object;
+
+ object = g_object_new (GDM_TYPE_TIMER, NULL);
+
+ return GDM_TIMER (object);
+}
+
+static double
+get_current_time (void)
+{
+ const double microseconds_per_second = 1000000.0;
+ double timestamp;
+ GTimeVal now;
+
+ g_get_current_time (&now);
+
+ timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) /
+ microseconds_per_second;
+
+ return timestamp;
+}
+
+static gboolean
+on_tick_timeout (GdmTimer *timer)
+{
+ double progress;
+ double time_before_tick;
+ double elapsed_time;
+
+ time_before_tick = get_current_time ();
+ elapsed_time = time_before_tick - timer->priv->start_time;
+ progress = elapsed_time / timer->priv->duration;
+
+ if (progress > 0.999) {
+ gdm_timer_stop (timer);
+ } else {
+ static const double frequency = 1.0 / GDM_TIMER_TICKS_PER_SECOND;
+ double next_tick;
+ double time_after_tick;
+ double tick_duration;
+
+ g_signal_emit (G_OBJECT (timer), signals[TICK], 0, progress);
+
+ time_after_tick = get_current_time ();
+ tick_duration = time_after_tick - time_before_tick;
+
+ next_tick = MAX (frequency - tick_duration, 0.0);
+ timer->priv->tick_timeout_id = 0;
+ gdm_timer_queue_next_tick (timer, next_tick);
+ }
+
+ return FALSE;
+}
+
+static void
+gdm_timer_clear_timeout (GdmTimer *timer)
+{
+ timer->priv->tick_timeout_id = 0;
+}
+
+static void
+gdm_timer_queue_next_tick (GdmTimer *timer,
+ double when)
+{
+ if (timer->priv->tick_timeout_id != 0) {
+ return;
+ }
+
+ if (!timer->priv->is_started) {
+ return;
+ }
+
+ timer->priv->tick_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT,
+ (guint) (when * 1000),
+ (GSourceFunc)
+ on_tick_timeout,
+ timer,
+ (GDestroyNotify)
+ gdm_timer_clear_timeout);
+}
+
+static void
+gdm_timer_set_is_started (GdmTimer *timer,
+ gboolean is_started)
+{
+ timer->priv->is_started = is_started;
+ g_object_notify (G_OBJECT (timer), "is-started");
+}
+
+void
+gdm_timer_start (GdmTimer *timer,
+ double number_of_seconds)
+{
+ g_return_if_fail (GDM_IS_TIMER (timer));
+ g_return_if_fail (number_of_seconds > G_MINDOUBLE);
+ g_return_if_fail (!timer->priv->is_started);
+
+ timer->priv->start_time = get_current_time ();
+ timer->priv->duration = number_of_seconds;
+
+ g_assert (timer->priv->tick_timeout_id == 0);
+ gdm_timer_set_is_started (timer, TRUE);
+ gdm_timer_queue_next_tick (timer, 1.0 / GDM_TIMER_TICKS_PER_SECOND);
+}
+
+void
+gdm_timer_stop (GdmTimer *timer)
+{
+ g_return_if_fail (GDM_IS_TIMER (timer));
+
+ if (!timer->priv->is_started) {
+ return;
+ }
+
+ if (timer->priv->tick_timeout_id != 0) {
+ g_source_remove (timer->priv->tick_timeout_id);
+ timer->priv->tick_timeout_id = 0;
+ }
+
+ gdm_timer_set_is_started (timer, FALSE);
+ g_signal_emit (G_OBJECT (timer), signals[STOP], 0);
+}
+
+gboolean
+gdm_timer_is_started (GdmTimer *timer)
+{
+ g_return_val_if_fail (GDM_IS_TIMER (timer), FALSE);
+
+ return timer->priv->is_started;
+}
Added: trunk/gui/simple-greeter/gdm-timer.h
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/gdm-timer.h Thu Apr 3 21:54:23 2008
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Written by: Ray Strode <rstrode redhat com>
+ */
+
+#ifndef GDM_TIMER_H
+#define GDM_TIMER_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GDM_TYPE_TIMER (gdm_timer_get_type ())
+#define GDM_TIMER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDM_TYPE_TIMER, GdmTimer))
+#define GDM_TIMER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDM_TYPE_TIMER, GdmTimerClass))
+#define GDM_IS_TIMER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDM_TYPE_TIMER))
+#define GDM_IS_TIMER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDM_TYPE_TIMER))
+#define GDM_TIMER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDM_TYPE_TIMER, GdmTimerClass))
+
+typedef struct GdmTimerPrivate GdmTimerPrivate;
+
+typedef struct
+{
+ GObject parent;
+ GdmTimerPrivate *priv;
+} GdmTimer;
+
+typedef struct
+{
+ GObjectClass parent_class;
+
+ void (* tick) (GdmTimer *timer, double progress);
+ void (* stop) (GdmTimer *timer);
+} GdmTimerClass;
+
+GType gdm_timer_get_type (void);
+GdmTimer *gdm_timer_new (void);
+#if 0
+GObject *gdm_timer_new_for_source (GdmTimerSource *source);
+#endif
+void gdm_timer_start (GdmTimer *timer,
+ double number_of_seconds);
+void gdm_timer_stop (GdmTimer *timer);
+gboolean gdm_timer_is_started (GdmTimer *timer);
+
+#endif /* GDM_TIMER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]