~kaozilon/totem/test

« back to all changes in this revision

Viewing changes to src/plugins/skipto/totem-time-entry.c

  • Committer: Bazaar Package Importer
  • Author(s): Sjoerd Simons, Josselin Mouette, Sjoerd Simons, Emilio Pozuelo Monfort
  • Date: 2009-04-19 17:28:51 UTC
  • mfrom: (1.2.52 upstream) (5.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090419172851-epoqimnq62akn294
Tags: 2.26.1-1
[ Josselin Mouette ]
* totem-plugins depends on python-gdbm. Closes: #523582.

[ Sjoerd Simons ]
* New upstream release (2.26.1)
* debian/patches/02_flv.patch: Dropped, fixed upstream
* debian/patches/04_tracker_build.patch: Dropped, fixed upstream
* debian/patches/01_fake_keypresses.patch: Updated and simplified
* debian/patches/70_bbc_plugin.patch: Updated
* debian/patches/90_autotools.patch: Updated

[ Emilio Pozuelo Monfort ]
* Recommend gnome-codec-install rather than gnome-app-install.
  Closes: #523052.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
/* 
 
3
 * Copyright (C) 2008 Philip Withnall <philip@tecnocode.co.uk>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
 
18
 *
 
19
 * The Totem project hereby grant permission for non-gpl compatible GStreamer
 
20
 * plugins to be used and distributed together with GStreamer and Totem. This
 
21
 * permission are above and beyond the permissions granted by the GPL license
 
22
 * Totem is covered by.
 
23
 *
 
24
 * Monday 7th February 2005: Christian Schaller: Add excemption clause.
 
25
 * See license_change file for details.
 
26
 *
 
27
 * Author: Philip Withnall <philip@tecnocode.co.uk>
 
28
 */
 
29
 
 
30
#include <glib.h>
 
31
#include <gtk/gtk.h>
 
32
 
 
33
#include "video-utils.h"
 
34
#include "totem-time-entry.h"
 
35
 
 
36
static gboolean output_cb (GtkSpinButton *self, gpointer user_data);
 
37
static gint input_cb (GtkSpinButton *self, gdouble *new_value, gpointer user_data);
 
38
 
 
39
G_DEFINE_TYPE (TotemTimeEntry, totem_time_entry, GTK_TYPE_SPIN_BUTTON)
 
40
 
 
41
static void
 
42
totem_time_entry_class_init (TotemTimeEntryClass *klass)
 
43
{
 
44
        /* Nothing to see here; please move along */
 
45
}
 
46
 
 
47
static void
 
48
totem_time_entry_init (TotemTimeEntry *self)
 
49
{
 
50
        /* Connect to signals */
 
51
        g_signal_connect (self, "output", G_CALLBACK (output_cb), NULL);
 
52
        g_signal_connect (self, "input", G_CALLBACK (input_cb), NULL);
 
53
}
 
54
 
 
55
GtkWidget *
 
56
totem_time_entry_new (GtkAdjustment *adjustment, gdouble climb_rate)
 
57
{
 
58
        return g_object_new (TOTEM_TYPE_TIME_ENTRY,
 
59
                             "adjustment", adjustment,
 
60
                             "climb-rate", climb_rate,
 
61
                             "digits", 0,
 
62
                             "numeric", FALSE,
 
63
                             NULL);
 
64
}
 
65
 
 
66
static gboolean
 
67
output_cb (GtkSpinButton *self, gpointer user_data)
 
68
{
 
69
        gchar *text;
 
70
 
 
71
        text = totem_time_to_string ((gint64) gtk_spin_button_get_value (self) * 1000);
 
72
        gtk_entry_set_text (GTK_ENTRY (self), text);
 
73
        g_free (text);
 
74
 
 
75
        return TRUE;
 
76
}
 
77
 
 
78
static gint
 
79
input_cb (GtkSpinButton *self, gdouble *new_value, gpointer user_data)
 
80
{
 
81
        gint64 val;
 
82
 
 
83
        val = totem_string_to_time (gtk_entry_get_text (GTK_ENTRY (self)));
 
84
        if (val == -1)
 
85
                return GTK_INPUT_ERROR;
 
86
 
 
87
        *new_value = val / 1000;
 
88
        return TRUE;
 
89
}