~ubuntu-branches/debian/sid/cheese/sid

« back to all changes in this revision

Viewing changes to src/cheese-prefs-burst-spinbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2011-07-17 21:04:16 UTC
  • mfrom: (15.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110717210416-nt5qi659qei7a2yy
Tags: 3.0.1-2
* debian/control.in:
  - Change gir1.2-cheese-3.0 Section to libs
  - Make library packages depend against cheese-common package
  - Make cheese package recommends against hicolor-icon-theme
  - Move gst Dependency to libcheese package
* debian/patches/0002-fix-linking.patch: Add missing library to fix linking
* debian/watch:
  - Switch to .bz2 tarballs.
  - Bump version to 3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2009 Aidan Delaney <a.j.delaney@brighton.ac.uk>
3
 
 * Copyright © 2009 daniel g. siegel <dgsiegel@gnome.org>
4
 
 * Copyright © 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
5
 
 *
6
 
 * Licensed under the GNU General Public License Version 2
7
 
 *
8
 
 * This program is free software; you can redistribute it and/or modify
9
 
 * it under the terms of the GNU General Public License as published by
10
 
 * the Free Software Foundation; either version 2 of the License, or
11
 
 * (at your option) any later version.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
 */
21
 
 
22
 
#include <string.h>
23
 
#include <glib.h>
24
 
 
25
 
#include "cheese-prefs-widget.h"
26
 
#include "cheese-prefs-burst-spinbox.h"
27
 
 
28
 
enum
29
 
{
30
 
  PROP_0,
31
 
  PROP_GCONF_KEY,
32
 
};
33
 
 
34
 
typedef struct CheesePrefsBurstSpinboxPrivate
35
 
{
36
 
  gchar *gconf_key;
37
 
} CheesePrefsBurstSpinboxPrivate;
38
 
 
39
 
#define CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE(o)                     \
40
 
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_PREFS_BURST_SPINBOX, \
41
 
                                CheesePrefsBurstSpinboxPrivate))
42
 
 
43
 
G_DEFINE_TYPE (CheesePrefsBurstSpinbox, cheese_prefs_burst_spinbox, CHEESE_TYPE_PREFS_WIDGET);
44
 
 
45
 
static void
46
 
cheese_prefs_burst_spinbox_init (CheesePrefsBurstSpinbox *self)
47
 
{
48
 
  CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
49
 
 
50
 
  priv->gconf_key = NULL;
51
 
}
52
 
 
53
 
static void
54
 
cheese_prefs_burst_spinbox_finalize (GObject *object)
55
 
{
56
 
  CheesePrefsBurstSpinbox        *self = CHEESE_PREFS_BURST_SPINBOX (object);
57
 
  CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
58
 
 
59
 
  g_free (priv->gconf_key);
60
 
 
61
 
  G_OBJECT_CLASS (cheese_prefs_burst_spinbox_parent_class)->finalize (object);
62
 
}
63
 
 
64
 
static void
65
 
cheese_prefs_burst_spinbox_value_changed (GtkSpinButton *spinbox, CheesePrefsBurstSpinbox *self)
66
 
{
67
 
  CheesePrefsBurstSpinboxPrivate *priv  = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
68
 
  int                             value = 0;
69
 
 
70
 
  if (strcmp ("gconf_prop_burst_delay", priv->gconf_key) == 0)
71
 
  {
72
 
    /* Inputted f is eg: 1.5s. Convert to millisec */
73
 
    gdouble d = gtk_spin_button_get_value (spinbox);
74
 
    value = (int) (d * 1000);
75
 
  }
76
 
  else
77
 
  {
78
 
    value = gtk_spin_button_get_value_as_int (spinbox);
79
 
  }
80
 
 
81
 
  g_object_set (CHEESE_PREFS_WIDGET (self)->gconf, priv->gconf_key, value, NULL);
82
 
  cheese_prefs_widget_notify_changed (CHEESE_PREFS_WIDGET (self));
83
 
}
84
 
 
85
 
static void
86
 
cheese_prefs_burst_spinbox_synchronize (CheesePrefsWidget *prefs_widget)
87
 
{
88
 
  CheesePrefsBurstSpinbox        *self = CHEESE_PREFS_BURST_SPINBOX (prefs_widget);
89
 
  CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
90
 
 
91
 
  GtkWidget *spinbox;
92
 
  int        stored_value;
93
 
 
94
 
  g_object_get (prefs_widget, "widget", &spinbox, NULL);
95
 
 
96
 
  g_object_get (CHEESE_PREFS_WIDGET (self)->gconf, priv->gconf_key, &stored_value, NULL);
97
 
 
98
 
  if (!g_ascii_strncasecmp ("gconf_prop_burst_delay", priv->gconf_key, 22))
99
 
  {
100
 
    stored_value = (int) (stored_value / 1000.0);
101
 
  }
102
 
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbox), stored_value);
103
 
 
104
 
  /* Disconnect to prevent a whole bunch of changed notifications */
105
 
  g_signal_handlers_disconnect_by_func (spinbox, cheese_prefs_burst_spinbox_value_changed, prefs_widget);
106
 
 
107
 
  g_signal_connect (G_OBJECT (spinbox), "value-changed",
108
 
                    G_CALLBACK (cheese_prefs_burst_spinbox_value_changed),
109
 
                    self);
110
 
}
111
 
 
112
 
static void
113
 
cheese_prefs_burst_spinbox_set_property (GObject *object, guint prop_id,
114
 
                                         const GValue *value,
115
 
                                         GParamSpec *pspec)
116
 
{
117
 
  CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (object);
118
 
 
119
 
  switch (prop_id)
120
 
  {
121
 
    case PROP_GCONF_KEY:
122
 
      priv->gconf_key = g_value_dup_string (value);
123
 
      break;
124
 
    default:
125
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
126
 
      break;
127
 
  }
128
 
}
129
 
 
130
 
static void
131
 
cheese_prefs_burst_spinbox_get_property (GObject *object, guint prop_id,
132
 
                                         GValue *value, GParamSpec *pspec)
133
 
{
134
 
  CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (object);
135
 
 
136
 
  g_return_if_fail (CHEESE_IS_PREFS_BURST_SPINBOX (object));
137
 
 
138
 
  switch (prop_id)
139
 
  {
140
 
    case PROP_GCONF_KEY:
141
 
      g_value_set_string (value, priv->gconf_key);
142
 
      break;
143
 
    default:
144
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
145
 
      break;
146
 
  }
147
 
}
148
 
 
149
 
static void
150
 
cheese_prefs_burst_spinbox_class_init (CheesePrefsBurstSpinboxClass *klass)
151
 
{
152
 
  GObjectClass           *object_class = G_OBJECT_CLASS (klass);
153
 
  CheesePrefsWidgetClass *parent_class = CHEESE_PREFS_WIDGET_CLASS (klass);
154
 
 
155
 
  g_type_class_add_private (klass, sizeof (CheesePrefsBurstSpinboxPrivate));
156
 
 
157
 
  object_class->finalize     = cheese_prefs_burst_spinbox_finalize;
158
 
  object_class->set_property = cheese_prefs_burst_spinbox_set_property;
159
 
  object_class->get_property = cheese_prefs_burst_spinbox_get_property;
160
 
  parent_class->synchronize  = cheese_prefs_burst_spinbox_synchronize;
161
 
 
162
 
  g_object_class_install_property (object_class,
163
 
                                   PROP_GCONF_KEY,
164
 
                                   g_param_spec_string ("gconf_key",
165
 
                                                        "",
166
 
                                                        "GConf key for burst mode",
167
 
                                                        "",
168
 
                                                        G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
169
 
}
170
 
 
171
 
CheesePrefsBurstSpinbox *
172
 
cheese_prefs_burst_spinbox_new (GtkWidget   *spinbox,
173
 
                                const gchar *gconf_key)
174
 
{
175
 
  CheesePrefsBurstSpinbox        *self;
176
 
  CheesePrefsBurstSpinboxPrivate *priv;
177
 
 
178
 
  self = g_object_new (CHEESE_TYPE_PREFS_BURST_SPINBOX,
179
 
                       "widget", spinbox,
180
 
                       "gconf_key", gconf_key,
181
 
                       NULL);
182
 
 
183
 
  priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
184
 
 
185
 
  return self;
186
 
}