~wongchiachen/ubuntu/precise/totem/hey_about_dialog

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-05-20 16:38:02 UTC
  • mfrom: (1.11.13 upstream) (2.1.17 experimental)
  • Revision ID: james.westby@ubuntu.com-20110520163802-p3lohdmfvws2jqeo
Tags: 3.0.1-0ubuntu1
* Resynchronize on Debian, remaining diffs:
* debian/control.in:
  - use suggests rather than recommends for universe gstreamer components
  - add totem-plugins-extra for the components which have depends in universe
  - add build-depends on gnome-common, dh-autoreconf, 
    liblaunchpad-intrgration-3.0-dev, hardening-wrapper
  - drop build-depends on libepc-ui-dev, python-feedparser, xulrunner-dev,
    libtracker-sparql-0.10-dev
  - add XB-Npp-Description and XB-Npp-Filename header to the 
    totem-mozilla package to improve ubufox/ubuntu plugin db integration 
  - change refences from Iceweasel to Firefox
  - recommends gnome-icon-theme-symbolic rather than depending on it
  - list firefox as a totem-mozilla recommends before epiphany-browser
  - libtotem replaces totem (<< 3.0.1-1) for ppa upgrades
* debian/totem-common.install:
  - Install apport hook
* debian/totem-plugins-extra.install:
  - Plugins split out ouf totem-plugins
* debian/totem-plugins.install:    
  - Move some plugins to totem-plugins-extra
* debian/totem.preinst:
  - No longer required as Lucid has been released
* debian/patches/01_fake_keypresses.patch:
  - dropped it's an old workaround and should not be required
* debian/patches/02_lpi.patch:
  - Launchpad integration
* debian/patches/03_default_options.patch: 
  - enable the youtube option by default
* debian/patches/70_bbc_plugin.patch:
  - bbc content viewer, needs to be fixed for the new version
* debian/source_totem.py:
  - ubuntu apport debugging
* debian/rules:
  - run autoreconf on build
* debian/watch:
  - Watch for unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 * Author: Philip Withnall <philip@tecnocode.co.uk>
28
28
 */
29
29
 
 
30
#include <string.h>
30
31
#include <glib.h>
31
32
#include <gtk/gtk.h>
32
33
 
33
 
#include "video-utils.h"
 
34
#include "backend/video-utils.h"
34
35
#include "totem-time-entry.h"
35
36
 
 
37
static void dispose (GObject *object);
36
38
static gboolean output_cb (GtkSpinButton *self, gpointer user_data);
37
39
static gint input_cb (GtkSpinButton *self, gdouble *new_value, gpointer user_data);
 
40
static void notify_adjustment_cb (TotemTimeEntry *self, GParamSpec *pspec, gpointer user_data);
 
41
static void changed_cb (GtkAdjustment *adjustment, TotemTimeEntry *self);
 
42
 
 
43
struct TotemTimeEntryPrivate {
 
44
        GtkAdjustment *adjustment;
 
45
        gulong adjustment_changed_signal;
 
46
};
38
47
 
39
48
G_DEFINE_TYPE (TotemTimeEntry, totem_time_entry, GTK_TYPE_SPIN_BUTTON)
40
49
 
41
50
static void
42
51
totem_time_entry_class_init (TotemTimeEntryClass *klass)
43
52
{
44
 
        /* Nothing to see here; please move along */
 
53
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
54
 
 
55
        g_type_class_add_private (klass, sizeof (TotemTimeEntryPrivate));
 
56
 
 
57
        object_class->dispose = dispose;
45
58
}
46
59
 
47
60
static void
48
61
totem_time_entry_init (TotemTimeEntry *self)
49
62
{
 
63
        self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TOTEM_TYPE_TIME_ENTRY, TotemTimeEntryPrivate);
 
64
 
50
65
        /* Connect to signals */
51
66
        g_signal_connect (self, "output", G_CALLBACK (output_cb), NULL);
52
67
        g_signal_connect (self, "input", G_CALLBACK (input_cb), NULL);
 
68
        g_signal_connect (self, "notify::adjustment", G_CALLBACK (notify_adjustment_cb), NULL);
 
69
}
 
70
 
 
71
static void
 
72
dispose (GObject *object)
 
73
{
 
74
        TotemTimeEntryPrivate *priv = TOTEM_TIME_ENTRY (object)->priv;
 
75
 
 
76
        if (priv->adjustment != NULL) {
 
77
                g_signal_handler_disconnect (priv->adjustment, priv->adjustment_changed_signal);
 
78
                g_object_unref (priv->adjustment);
 
79
        }
 
80
        priv->adjustment = NULL;
 
81
 
 
82
        G_OBJECT_CLASS (totem_time_entry_parent_class)->dispose (object);
53
83
}
54
84
 
55
85
GtkWidget *
87
117
        *new_value = val / 1000;
88
118
        return TRUE;
89
119
}
 
120
 
 
121
static void
 
122
notify_adjustment_cb (TotemTimeEntry *self, GParamSpec *pspec, gpointer user_data)
 
123
{
 
124
        TotemTimeEntryPrivate *priv = self->priv;
 
125
 
 
126
        if (priv->adjustment != NULL) {
 
127
                g_signal_handler_disconnect (priv->adjustment, priv->adjustment_changed_signal);
 
128
                g_object_unref (priv->adjustment);
 
129
        }
 
130
 
 
131
        priv->adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (self));
 
132
        priv->adjustment_changed_signal = 0;
 
133
 
 
134
        if (priv->adjustment != NULL) {
 
135
                g_object_ref (priv->adjustment);
 
136
                priv->adjustment_changed_signal = g_signal_connect (priv->adjustment, "changed", G_CALLBACK (changed_cb), self);
 
137
        }
 
138
}
 
139
 
 
140
static void
 
141
changed_cb (GtkAdjustment *adjustment, TotemTimeEntry *self)
 
142
{
 
143
        gchar *time_string;
 
144
        guint upper, width;
 
145
 
 
146
        /* Set the width of the entry according to the length of the longest string it'll now accept */
 
147
        upper = (guint) gtk_adjustment_get_upper (adjustment); /* in seconds */
 
148
 
 
149
        time_string = totem_time_to_string (((gint64) upper) * 1000);
 
150
        width = strlen (time_string);
 
151
        g_free (time_string);
 
152
 
 
153
        gtk_entry_set_width_chars (GTK_ENTRY (self), width);
 
154
}