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>
6
* Licensed under the GNU General Public License Version 2
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.
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.
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/>.
25
#include "cheese-prefs-widget.h"
26
#include "cheese-prefs-burst-spinbox.h"
34
typedef struct CheesePrefsBurstSpinboxPrivate
37
} CheesePrefsBurstSpinboxPrivate;
39
#define CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE(o) \
40
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_PREFS_BURST_SPINBOX, \
41
CheesePrefsBurstSpinboxPrivate))
43
G_DEFINE_TYPE (CheesePrefsBurstSpinbox, cheese_prefs_burst_spinbox, CHEESE_TYPE_PREFS_WIDGET);
46
cheese_prefs_burst_spinbox_init (CheesePrefsBurstSpinbox *self)
48
CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
50
priv->gconf_key = NULL;
54
cheese_prefs_burst_spinbox_finalize (GObject *object)
56
CheesePrefsBurstSpinbox *self = CHEESE_PREFS_BURST_SPINBOX (object);
57
CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
59
g_free (priv->gconf_key);
61
G_OBJECT_CLASS (cheese_prefs_burst_spinbox_parent_class)->finalize (object);
65
cheese_prefs_burst_spinbox_value_changed (GtkSpinButton *spinbox, CheesePrefsBurstSpinbox *self)
67
CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
70
if (strcmp ("gconf_prop_burst_delay", priv->gconf_key) == 0)
72
/* Inputted f is eg: 1.5s. Convert to millisec */
73
gdouble d = gtk_spin_button_get_value (spinbox);
74
value = (int) (d * 1000);
78
value = gtk_spin_button_get_value_as_int (spinbox);
81
g_object_set (CHEESE_PREFS_WIDGET (self)->gconf, priv->gconf_key, value, NULL);
82
cheese_prefs_widget_notify_changed (CHEESE_PREFS_WIDGET (self));
86
cheese_prefs_burst_spinbox_synchronize (CheesePrefsWidget *prefs_widget)
88
CheesePrefsBurstSpinbox *self = CHEESE_PREFS_BURST_SPINBOX (prefs_widget);
89
CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);
94
g_object_get (prefs_widget, "widget", &spinbox, NULL);
96
g_object_get (CHEESE_PREFS_WIDGET (self)->gconf, priv->gconf_key, &stored_value, NULL);
98
if (!g_ascii_strncasecmp ("gconf_prop_burst_delay", priv->gconf_key, 22))
100
stored_value = (int) (stored_value / 1000.0);
102
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbox), stored_value);
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);
107
g_signal_connect (G_OBJECT (spinbox), "value-changed",
108
G_CALLBACK (cheese_prefs_burst_spinbox_value_changed),
113
cheese_prefs_burst_spinbox_set_property (GObject *object, guint prop_id,
117
CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (object);
122
priv->gconf_key = g_value_dup_string (value);
125
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
131
cheese_prefs_burst_spinbox_get_property (GObject *object, guint prop_id,
132
GValue *value, GParamSpec *pspec)
134
CheesePrefsBurstSpinboxPrivate *priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (object);
136
g_return_if_fail (CHEESE_IS_PREFS_BURST_SPINBOX (object));
141
g_value_set_string (value, priv->gconf_key);
144
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
150
cheese_prefs_burst_spinbox_class_init (CheesePrefsBurstSpinboxClass *klass)
152
GObjectClass *object_class = G_OBJECT_CLASS (klass);
153
CheesePrefsWidgetClass *parent_class = CHEESE_PREFS_WIDGET_CLASS (klass);
155
g_type_class_add_private (klass, sizeof (CheesePrefsBurstSpinboxPrivate));
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;
162
g_object_class_install_property (object_class,
164
g_param_spec_string ("gconf_key",
166
"GConf key for burst mode",
168
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
171
CheesePrefsBurstSpinbox *
172
cheese_prefs_burst_spinbox_new (GtkWidget *spinbox,
173
const gchar *gconf_key)
175
CheesePrefsBurstSpinbox *self;
176
CheesePrefsBurstSpinboxPrivate *priv;
178
self = g_object_new (CHEESE_TYPE_PREFS_BURST_SPINBOX,
180
"gconf_key", gconf_key,
183
priv = CHEESE_PREFS_BURST_SPINBOX_GET_PRIVATE (self);