PIKApp/libpikawidgets/pikacolorscaleentry.c

113 lines
3.2 KiB
C
Raw Permalink Normal View History

2023-09-26 00:35:21 +02:00
/* LIBPIKA - The PIKA Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* pikacolorscaleentry.c
* Copyright (C) 2020 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library 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, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikacolor/pikacolor.h"
#include "libpikamath/pikamath.h"
#include "libpikabase/pikabase.h"
#include "pikawidgets.h"
/**
* SECTION: pikacolorscaleentry
* @title: PikaColorScaleEntry
* @short_description: Widget containing a color scale, a spin button
* and a label.
*
* This widget is a subclass of #PikaScaleEntry showing a
* #PikaColorScale instead of a #GtkScale.
**/
struct _PikaColorScaleEntry
{
PikaScaleEntry parent_instance;
};
static GtkWidget * pika_color_scale_entry_new_range_widget (GtkAdjustment *adjustment);
G_DEFINE_TYPE (PikaColorScaleEntry, pika_color_scale_entry, PIKA_TYPE_SCALE_ENTRY)
#define parent_class pika_color_scale_entry_parent_class
static void
pika_color_scale_entry_class_init (PikaColorScaleEntryClass *klass)
{
PikaScaleEntryClass *entry_class = PIKA_SCALE_ENTRY_CLASS (klass);
entry_class->new_range_widget = pika_color_scale_entry_new_range_widget;
}
static void
pika_color_scale_entry_init (PikaColorScaleEntry *entry)
{
}
static GtkWidget *
pika_color_scale_entry_new_range_widget (GtkAdjustment *adjustment)
{
GtkWidget *scale;
g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
scale = pika_color_scale_new (GTK_ORIENTATION_HORIZONTAL,
PIKA_COLOR_SELECTOR_VALUE);
gtk_range_set_adjustment (GTK_RANGE (scale), adjustment);
return scale;
}
/**
* pika_color_scale_entry_new:
* @text: The text for the #GtkLabel.
* @value: The initial value.
* @lower: The lower boundary.
* @upper: The upper boundary.
* @digits: The number of decimal digits.
*
* Returns: (transfer full): The new #PikaColorScale widget.
**/
GtkWidget *
pika_color_scale_entry_new (const gchar *text,
gdouble value,
gdouble lower,
gdouble upper,
guint digits)
{
GtkWidget *entry;
entry = g_object_new (PIKA_TYPE_COLOR_SCALE_ENTRY,
"label", text,
"value", value,
"lower", lower,
"upper", upper,
"digits", digits,
NULL);
return entry;
}