* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Lorenzo Gil Sanchez <lgs@sicem.biz>
* Carlos Garnacho Parro <carlosg@gnome.org>
*/
#include "config.h"
-#include <gdk/gdkkeysyms.h>
+
+#include "gtkcellrendererspin.h"
+
+#include "gtkadjustment.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkspinbutton.h"
-#include "gtkcellrendererspin.h"
+
+
+/**
+ * SECTION:gtkcellrendererspin
+ * @Short_description: Renders a spin button in a cell
+ * @Title: GtkCellRendererSpin
+ * @See_also: #GtkCellRendererText, #GtkSpinButton
+ *
+ * #GtkCellRendererSpin renders text in a cell like #GtkCellRendererText from
+ * which it is derived. But while #GtkCellRendererText offers a simple entry to
+ * edit the text, #GtkCellRendererSpin offers a #GtkSpinButton widget. Of course,
+ * that means that the text has to be parseable as a floating point number.
+ *
+ * The range of the spinbutton is taken from the adjustment property of the
+ * cell renderer, which can be set explicitly or mapped to a column in the
+ * tree model, like all properties of cell renders. #GtkCellRendererSpin
+ * also has properties for the #GtkCellRendererSpin:climb-rate and the number
+ * of #GtkCellRendererSpin:digits to display. Other #GtkSpinButton properties
+ * can be set in a handler for the #GtkCellRenderer::editing-started signal.
+ *
+ * The #GtkCellRendererSpin cell renderer was added in GTK+ 2.10.
+ */
struct _GtkCellRendererSpinPrivate
GdkEvent *event,
GtkWidget *widget,
const gchar *path,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
GtkCellRendererState flags);
enum {
PROP_0,
PROP_ADJUSTMENT,
g_param_spec_object ("adjustment",
P_("Adjustment"),
- P_("The adjustment that holds the value of the spinbutton."),
+ P_("The adjustment that holds the value of the spin button"),
GTK_TYPE_ADJUSTMENT,
GTK_PARAM_READWRITE));
{
if (event->state == 0)
{
- if (event->keyval == GDK_Up)
+ if (event->keyval == GDK_KEY_Up)
{
gtk_spin_button_spin (GTK_SPIN_BUTTON (widget), GTK_SPIN_STEP_FORWARD, 1);
return TRUE;
}
- else if (event->keyval == GDK_Down)
+ else if (event->keyval == GDK_KEY_Down)
{
gtk_spin_button_spin (GTK_SPIN_BUTTON (widget), GTK_SPIN_STEP_BACKWARD, 1);
return TRUE;
}
static GtkCellEditable *
-gtk_cell_renderer_spin_start_editing (GtkCellRenderer *cell,
- GdkEvent *event,
- GtkWidget *widget,
- const gchar *path,
- GdkRectangle *background_area,
- GdkRectangle *cell_area,
- GtkCellRendererState flags)
+gtk_cell_renderer_spin_start_editing (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags)
{
GtkCellRendererSpinPrivate *priv;
GtkCellRendererText *cell_text;
g_object_get (cell_text, "text", &text, NULL);
if (text)
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin),
- g_ascii_strtod (text, NULL));
- g_free (text);
+ {
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin),
+ g_strtod (text, NULL));
+ g_free (text);
+ }
g_object_set_data_full (G_OBJECT (spin), GTK_CELL_RENDERER_SPIN_PATH,
g_strdup (path), g_free);