2008-07-01 22:57:50 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
* Copyright (C) 1997 David Mosberger
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2006-07-04 03:50:37 +00:00
|
|
|
#include <gdk-pixbuf/gdk-pixdata.h>
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtkgamma.h"
|
|
|
|
#include "gtkcurve.h"
|
|
|
|
#include "gtkdialog.h"
|
|
|
|
#include "gtkdrawingarea.h"
|
|
|
|
#include "gtkentry.h"
|
|
|
|
#include "gtkhbox.h"
|
2002-10-13 20:44:18 +00:00
|
|
|
#include "gtkimage.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtkmain.h"
|
|
|
|
#include "gtkradiobutton.h"
|
2002-02-08 17:35:06 +00:00
|
|
|
#include "gtkstock.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtktable.h"
|
|
|
|
#include "gtkvbox.h"
|
|
|
|
#include "gtkwindow.h"
|
1998-12-18 01:32:33 +00:00
|
|
|
#include "gtkintl.h"
|
2005-03-20 07:01:23 +00:00
|
|
|
#include "gtkalias.h"
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
/* forward declarations: */
|
|
|
|
static void gtk_gamma_curve_destroy (GtkObject *object);
|
|
|
|
|
1998-03-18 21:11:04 +00:00
|
|
|
static void curve_type_changed_callback (GtkWidget *w, gpointer data);
|
|
|
|
static void button_realize_callback (GtkWidget *w);
|
|
|
|
static void button_toggled_callback (GtkWidget *w, gpointer data);
|
|
|
|
static void button_clicked_callback (GtkWidget *w, gpointer data);
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
LINEAR = 0,
|
|
|
|
SPLINE,
|
|
|
|
FREE,
|
|
|
|
GAMMA,
|
|
|
|
RESET,
|
|
|
|
NUM_XPMS
|
|
|
|
};
|
|
|
|
|
2006-07-04 03:50:37 +00:00
|
|
|
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
|
|
|
|
|
|
|
|
#ifdef __SUNPRO_C
|
|
|
|
#pragma align 4 (spline_pixdata)
|
|
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static const guint8 spline_pixdata[] __attribute__ ((__aligned__ (4))) =
|
|
|
|
#else
|
|
|
|
static const guint8 spline_pixdata[] =
|
|
|
|
#endif
|
|
|
|
{ ""
|
|
|
|
/* Pixbuf magic (0x47646b50) */
|
|
|
|
"GdkP"
|
|
|
|
/* length: header (24) + pixel_data (182) */
|
|
|
|
"\0\0\0\316"
|
|
|
|
/* pixdata_type (0x2010002) */
|
|
|
|
"\2\1\0\2"
|
|
|
|
/* rowstride (64) */
|
|
|
|
"\0\0\0@"
|
|
|
|
/* width (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* height (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* pixel_data: */
|
|
|
|
"\216\0\0\0\0\202\0\0\0\377\211\0\0\0\0\206\377\0\0\377\1\0\0\0\377\207"
|
|
|
|
"\0\0\0\0\202\377\0\0\377\214\0\0\0\0\2\0\0\0\377\274--\377\215\0\0\0"
|
|
|
|
"\0\203\0\0\0\377\215\0\0\0\0\2\274--\377\0\0\0\377\216\0\0\0\0\1\377"
|
|
|
|
"\0\0\377\216\0\0\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377\216\0\0"
|
|
|
|
"\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377"
|
|
|
|
"\217\0\0\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377\216\0\0\0\0\2\0"
|
|
|
|
"\0\0\377\274--\377\216\0\0\0\0\202\0\0\0\377\216\0\0\0\0"};
|
|
|
|
|
|
|
|
|
|
|
|
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
|
|
|
|
|
|
|
|
#ifdef __SUNPRO_C
|
|
|
|
#pragma align 4 (linear_pixdata)
|
|
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static const guint8 linear_pixdata[] __attribute__ ((__aligned__ (4))) =
|
|
|
|
#else
|
|
|
|
static const guint8 linear_pixdata[] =
|
|
|
|
#endif
|
|
|
|
{ ""
|
|
|
|
/* Pixbuf magic (0x47646b50) */
|
|
|
|
"GdkP"
|
|
|
|
/* length: header (24) + pixel_data (323) */
|
|
|
|
"\0\0\1["
|
|
|
|
/* pixdata_type (0x2010002) */
|
|
|
|
"\2\1\0\2"
|
|
|
|
/* rowstride (64) */
|
|
|
|
"\0\0\0@"
|
|
|
|
/* width (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* height (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* pixel_data: */
|
|
|
|
"\216\0\0\0\0\202\0\0\0\377\216\0\0\0\0\2\202AA\377\0\0\0\377\216\0\0"
|
|
|
|
"\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377"
|
|
|
|
"\206\0\0\0\0\3\177\177\177\377\0\0\0\377\177\177\177\377\205\0\0\0\0"
|
|
|
|
"\1\377\0\0\377\207\0\0\0\0\203\0\0\0\377\205\0\0\0\0\1\377\0\0\377\207"
|
|
|
|
"\0\0\0\0\3\202AA\377\0\0\0\377\202AA\377\204\0\0\0\0\1\377\0\0\377\210"
|
|
|
|
"\0\0\0\0\3\377\0\0\377\0\0\0\0\377\0\0\377\204\0\0\0\0\1\377\0\0\377"
|
|
|
|
"\207\0\0\0\0\1\377\0\0\377\203\0\0\0\0\1\377\0\0\377\202\0\0\0\0\1\377"
|
|
|
|
"\0\0\377\210\0\0\0\0\1\377\0\0\377\203\0\0\0\0\1\377\0\0\377\202\0\0"
|
|
|
|
"\0\0\1\377\0\0\377\207\0\0\0\0\1\377\0\0\377\205\0\0\0\0\3\377\0\0\377"
|
|
|
|
"\0\0\0\377\202AA\377\207\0\0\0\0\1\377\0\0\377\205\0\0\0\0\203\0\0\0"
|
|
|
|
"\377\206\0\0\0\0\1\377\0\0\377\206\0\0\0\0\3\177\177\177\377\0\0\0\377"
|
|
|
|
"\177\177\177\377\205\0\0\0\0\2\0\0\0\377\202AA\377\216\0\0\0\0\202\0"
|
|
|
|
"\0\0\377\216\0\0\0\0"};
|
|
|
|
|
|
|
|
|
|
|
|
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
|
|
|
|
|
|
|
|
#ifdef __SUNPRO_C
|
|
|
|
#pragma align 4 (free_pixdata)
|
|
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static const guint8 free_pixdata[] __attribute__ ((__aligned__ (4))) =
|
|
|
|
#else
|
|
|
|
static const guint8 free_pixdata[] =
|
|
|
|
#endif
|
|
|
|
{ ""
|
|
|
|
/* Pixbuf magic (0x47646b50) */
|
|
|
|
"GdkP"
|
|
|
|
/* length: header (24) + pixel_data (204) */
|
|
|
|
"\0\0\0\344"
|
|
|
|
/* pixdata_type (0x2010002) */
|
|
|
|
"\2\1\0\2"
|
|
|
|
/* rowstride (64) */
|
|
|
|
"\0\0\0@"
|
|
|
|
/* width (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* height (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* pixel_data: */
|
|
|
|
"\246\0\0\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377\220\0\0\0\0\1\377"
|
|
|
|
"\0\0\377\217\0\0\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377\220\0\0"
|
|
|
|
"\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377\217\0\0\0\0\1\377\0\0\377"
|
|
|
|
"\214\0\0\0\0\1\377\0\0\377\203\0\0\0\0\2\377\0\0\377\0\0\0\0\205\377"
|
|
|
|
"\0\0\377\204\0\0\0\0\1\377\0\0\377\204\0\0\0\0\1\377\0\0\377\211\0\0"
|
|
|
|
"\0\0\1\377\0\0\377\205\0\0\0\0\1\377\0\0\377\210\0\0\0\0\1\377\0\0\377"
|
|
|
|
"\207\0\0\0\0\1\377\0\0\377\206\0\0\0\0\1\377\0\0\377\210\0\0\0\0\1\377"
|
|
|
|
"\0\0\377\205\0\0\0\0\1\377\0\0\377\217\0\0\0\0"};
|
|
|
|
|
|
|
|
|
|
|
|
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
|
|
|
|
|
|
|
|
#ifdef __SUNPRO_C
|
|
|
|
#pragma align 4 (gamma_pixdata)
|
|
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static const guint8 gamma_pixdata[] __attribute__ ((__aligned__ (4))) =
|
|
|
|
#else
|
|
|
|
static const guint8 gamma_pixdata[] =
|
|
|
|
#endif
|
|
|
|
{ ""
|
|
|
|
/* Pixbuf magic (0x47646b50) */
|
|
|
|
"GdkP"
|
|
|
|
/* length: header (24) + pixel_data (218) */
|
|
|
|
"\0\0\0\362"
|
|
|
|
/* pixdata_type (0x2010002) */
|
|
|
|
"\2\1\0\2"
|
|
|
|
/* rowstride (64) */
|
|
|
|
"\0\0\0@"
|
|
|
|
/* width (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* height (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* pixel_data: */
|
|
|
|
"\264\0\0\0\0\2\0\0\0\377^^^\377\202\0\0\0\0\3\214\214\214\377\0\0\0\377"
|
|
|
|
"\214\214\214\377\211\0\0\0\0\7FFF\377\27\27\27\377\273\273\273\377\0"
|
|
|
|
"\0\0\0uuu\377\27\27\27\377\244\244\244\377\212\0\0\0\0\3uuu\377\214\214"
|
|
|
|
"\214\377\0\0\0\0\202FFF\377\214\0\0\0\0\4\0\0\0\377\0\0\0\0\0\0\0\377"
|
|
|
|
"\214\214\214\377\214\0\0\0\0\3FFF\377\0\0\0\0FFF\377\215\0\0\0\0\3FF"
|
|
|
|
"F\377\27\27\27\377\214\214\214\377\215\0\0\0\0\2\244\244\244\377\0\0"
|
|
|
|
"\0\377\216\0\0\0\0\2uuu\377^^^\377\216\0\0\0\0\2///\377\0\0\0\377\216"
|
|
|
|
"\0\0\0\0\202\0\0\0\377\216\0\0\0\0\2\0\0\0\377///\377\250\0\0\0\0"};
|
|
|
|
|
|
|
|
|
|
|
|
/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */
|
|
|
|
|
|
|
|
#ifdef __SUNPRO_C
|
|
|
|
#pragma align 4 (reset_pixdata)
|
|
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
|
|
static const guint8 reset_pixdata[] __attribute__ ((__aligned__ (4))) =
|
|
|
|
#else
|
|
|
|
static const guint8 reset_pixdata[] =
|
|
|
|
#endif
|
|
|
|
{ ""
|
|
|
|
/* Pixbuf magic (0x47646b50) */
|
|
|
|
"GdkP"
|
|
|
|
/* length: header (24) + pixel_data (173) */
|
|
|
|
"\0\0\0\305"
|
|
|
|
/* pixdata_type (0x2010002) */
|
|
|
|
"\2\1\0\2"
|
|
|
|
/* rowstride (64) */
|
|
|
|
"\0\0\0@"
|
|
|
|
/* width (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* height (16) */
|
|
|
|
"\0\0\0\20"
|
|
|
|
/* pixel_data: */
|
|
|
|
"\216\0\0\0\0\202\0\0\0\377\216\0\0\0\0\2\202AA\377\0\0\0\377\215\0\0"
|
|
|
|
"\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377"
|
|
|
|
"\216\0\0\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377\216\0\0\0\0\1\377"
|
|
|
|
"\0\0\377\216\0\0\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377\216\0\0"
|
|
|
|
"\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377\216\0\0\0\0\1\377\0\0\377"
|
|
|
|
"\216\0\0\0\0\1\377\0\0\377\215\0\0\0\0\2\0\0\0\377\202AA\377\216\0\0"
|
|
|
|
"\0\0\202\0\0\0\377\216\0\0\0\0"};
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2006-05-14 04:25:34 +00:00
|
|
|
G_DEFINE_TYPE (GtkGammaCurve, gtk_gamma_curve, GTK_TYPE_VBOX)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gamma_curve_class_init (GtkGammaCurveClass *class)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass *) class;
|
|
|
|
object_class->destroy = gtk_gamma_curve_destroy;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gamma_curve_init (GtkGammaCurve *curve)
|
|
|
|
{
|
1998-03-18 21:11:04 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
int i;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
curve->gamma = 1.0;
|
1998-03-18 21:11:04 +00:00
|
|
|
|
|
|
|
curve->table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (curve->table), 3);
|
|
|
|
gtk_container_add (GTK_CONTAINER (curve), curve->table);
|
|
|
|
|
|
|
|
curve->curve = gtk_curve_new ();
|
2008-08-12 14:37:03 +00:00
|
|
|
g_signal_connect (curve->curve, "curve-type-changed",
|
2002-10-13 20:44:18 +00:00
|
|
|
G_CALLBACK (curve_type_changed_callback), curve);
|
1998-03-18 21:11:04 +00:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (curve->table), curve->curve, 0, 1, 0, 1);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (/* homogeneous */ FALSE, /* spacing */ 3);
|
|
|
|
gtk_table_attach (GTK_TABLE (curve->table), vbox, 1, 2, 0, 1, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
/* toggle buttons: */
|
|
|
|
for (i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
curve->button[i] = gtk_toggle_button_new ();
|
2005-09-01 05:11:46 +00:00
|
|
|
g_object_set_data (G_OBJECT (curve->button[i]), I_("_GtkGammaCurveIndex"),
|
2002-10-13 20:44:18 +00:00
|
|
|
GINT_TO_POINTER (i));
|
1998-03-18 21:11:04 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), curve->button[i]);
|
2002-10-13 20:44:18 +00:00
|
|
|
g_signal_connect (curve->button[i], "realize",
|
|
|
|
G_CALLBACK (button_realize_callback), NULL);
|
|
|
|
g_signal_connect (curve->button[i], "toggled",
|
|
|
|
G_CALLBACK (button_toggled_callback), curve);
|
1998-03-18 21:11:04 +00:00
|
|
|
gtk_widget_show (curve->button[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* push buttons: */
|
|
|
|
for (i = 3; i < 5; ++i)
|
|
|
|
{
|
|
|
|
curve->button[i] = gtk_button_new ();
|
2005-09-01 05:11:46 +00:00
|
|
|
g_object_set_data (G_OBJECT (curve->button[i]), I_("_GtkGammaCurveIndex"),
|
2002-10-13 20:44:18 +00:00
|
|
|
GINT_TO_POINTER (i));
|
1998-03-18 21:11:04 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), curve->button[i]);
|
2002-10-13 20:44:18 +00:00
|
|
|
g_signal_connect (curve->button[i], "realize",
|
|
|
|
G_CALLBACK (button_realize_callback), NULL);
|
|
|
|
g_signal_connect (curve->button[i], "clicked",
|
|
|
|
G_CALLBACK (button_clicked_callback), curve);
|
1998-03-18 21:11:04 +00:00
|
|
|
gtk_widget_show (curve->button[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (curve->table);
|
|
|
|
gtk_widget_show (curve->curve);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
button_realize_callback (GtkWidget *w)
|
|
|
|
{
|
2006-07-04 03:50:37 +00:00
|
|
|
GtkWidget *image;
|
|
|
|
struct {
|
|
|
|
const guint8 *stream;
|
|
|
|
gint length;
|
|
|
|
} streams[5] = {
|
|
|
|
{ linear_pixdata, sizeof (linear_pixdata) },
|
|
|
|
{ spline_pixdata, sizeof (spline_pixdata) },
|
|
|
|
{ free_pixdata, sizeof (free_pixdata) },
|
|
|
|
{ gamma_pixdata, sizeof (gamma_pixdata) },
|
|
|
|
{ reset_pixdata, sizeof (reset_pixdata) }
|
|
|
|
};
|
|
|
|
GdkPixdata pixdata;
|
|
|
|
GdkPixbuf *pixbuf;
|
1997-11-24 22:37:52 +00:00
|
|
|
int i;
|
|
|
|
|
2002-10-13 20:44:18 +00:00
|
|
|
i = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "_GtkGammaCurveIndex"));
|
2006-07-04 03:50:37 +00:00
|
|
|
gdk_pixdata_deserialize (&pixdata, streams[i].length, streams[i].stream, NULL);
|
|
|
|
pixbuf = gdk_pixbuf_from_pixdata (&pixdata, TRUE, NULL);
|
|
|
|
image = gtk_image_new_from_pixbuf (pixbuf);
|
|
|
|
gtk_container_add (GTK_CONTAINER (w), image);
|
|
|
|
gtk_widget_show (image);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2006-07-04 03:50:37 +00:00
|
|
|
g_object_unref (pixbuf);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
button_toggled_callback (GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
GtkGammaCurve *c = data;
|
|
|
|
GtkCurveType type;
|
|
|
|
int active, i;
|
|
|
|
|
|
|
|
if (!GTK_TOGGLE_BUTTON (w)->active)
|
|
|
|
return;
|
|
|
|
|
2002-10-13 20:44:18 +00:00
|
|
|
active = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "_GtkGammaCurveIndex"));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; ++i)
|
|
|
|
if ((i != active) && GTK_TOGGLE_BUTTON (c->button[i])->active)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i < 3)
|
1999-01-11 18:49:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (c->button[i]), FALSE);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
switch (active)
|
|
|
|
{
|
|
|
|
case 0: type = GTK_CURVE_TYPE_SPLINE; break;
|
|
|
|
case 1: type = GTK_CURVE_TYPE_LINEAR; break;
|
|
|
|
default: type = GTK_CURVE_TYPE_FREE; break;
|
|
|
|
}
|
|
|
|
gtk_curve_set_curve_type (GTK_CURVE (c->curve), type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gamma_cancel_callback (GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
GtkGammaCurve *c = data;
|
|
|
|
|
|
|
|
gtk_widget_destroy (c->gamma_dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gamma_ok_callback (GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
GtkGammaCurve *c = data;
|
2001-10-26 15:44:20 +00:00
|
|
|
const gchar *start;
|
|
|
|
gchar *end;
|
1997-11-24 22:37:52 +00:00
|
|
|
gfloat v;
|
|
|
|
|
|
|
|
start = gtk_entry_get_text (GTK_ENTRY (c->gamma_text));
|
|
|
|
if (start)
|
|
|
|
{
|
2003-08-29 19:38:07 +00:00
|
|
|
v = g_strtod (start, &end);
|
1997-11-24 22:37:52 +00:00
|
|
|
if (end > start && v > 0.0)
|
|
|
|
c->gamma = v;
|
|
|
|
}
|
|
|
|
gtk_curve_set_gamma (GTK_CURVE (c->curve), c->gamma);
|
|
|
|
gamma_cancel_callback (w, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
button_clicked_callback (GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
GtkGammaCurve *c = data;
|
|
|
|
int active;
|
|
|
|
|
2002-10-13 20:44:18 +00:00
|
|
|
active = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "_GtkGammaCurveIndex"));
|
1997-11-24 22:37:52 +00:00
|
|
|
if (active == 3)
|
1998-02-18 10:03:54 +00:00
|
|
|
{
|
|
|
|
/* set gamma */
|
|
|
|
if (c->gamma_dialog)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkWidget *vbox, *hbox, *label, *button;
|
|
|
|
gchar buf[64];
|
|
|
|
|
|
|
|
c->gamma_dialog = gtk_dialog_new ();
|
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
Mon Apr 29 18:28:00 2002 Owen Taylor <otaylor@redhat.com>
Integrate Erwann Chenede's multihead changes for the gtk/ directory.
* gtk/gtkclipboard.[ch]: Add gtk_clipboard_get_for_display(),
make internals multihead aware.
* gtk/gtkcolorsel.[ch]: Add
gtk_color_selection_set_change_palette_with_screen_hook () [ugh!]
make up for non-multihead safety of
gtk_color_selection_set_change_palette_hook()
* gtk/gtkinvisible.[ch] gtk/gtkmenu.[ch] gtkwindow.[ch]: Add
gtk_{invisible,menu,window}_set_screen(); add "screen" properties
for GtkWindow and GtkMenu.
* gtk/gtkplug.[ch]: Add gtk_plug_construct_for_display(),
gtk_plug_new_for_display(). Multihead fixes.
* gtk/gtkselection.[ch]: Add gtk_selection_owner_set_for_display(),
make internals multihead aware.
* gtk/gtksettings.[ch]: Add gtk_settings_get_for_screen(), get
rid of now-useless gtk_settings_constructor().
* gtk/gtkstyle.[ch]: Add gtk_style_get_font_for_display(), fix
check/radio button indicators bitmap handling to be multihead
safe.
* gtk/gtkwidget.[ch]: Add gtk_widget_get_screen(), gtk_widget_has_screen(),
gtk_widget_get_display(), gtk_widget_get_clipboard(),
gtk_widget_get_root_window().
* gtk/gtkbindings.c gtk/gtkbutton.c gtk/gtkclist.c gtk/gtkcombo.c
gtk/gtkctree.c gtk/gtkdnd.c gtk/gtkfilesel.c gtk/gtkgamma.c
gtk/gtkhandlebox.c gtk/gtkhsv.c gtk/gtkimcontext.c gtk/gtklabel.c
gtk/gtklist.c gtk/gtkmain.c gtk/gtkmenuitem.c gtk/gtkmenushell.c
gtk/gtknotebook.c gtk/gtkoldeditable.c gtk/gtkoptionmenu.c
gtk/gtkpaned.c gtk/gtkpreview.c gtk/gtksocket.c gtk/gtktext.c
gtk/gtktextbuffer.c gtk/gtktextview.c gtk/gtktipsquery.c
gtk/gtktooltips.c gtk/gtktreeview.c gtk/gtktreeviewcolumn.c:
misc mechanical multihead-safety fixes.
* gtk/gtkclipboard.c: Use a GtkImage rather than a pixmap for
the dropper, look up the color palette only at realization time,
other multihead fixes.
* gtk/gtkcombo.c (gtk_combo_unrealize): Popdown the list when
unrealizing.
* gtk/gtkentry.c: Only claim ownership of the primary selection
when realized, misc multihead fixes.
* gtk/gtkfontsel.c: Only fill in fonts when attached to a screen,
fix gtk_font_selection_get_font() for multihead.
* gtk/gtkgc.c: make the depth => drawable hash per-screen.
* gtk/gtkinvisible.c: Add a constructor that realizes the
widget, so we get a realized widget with g_object_new() as
well gtk_invisible_new() as before.
* gtk/gtkmain.c: Get rid of unused gtk_visual/gtk_colormap
variables.
* gtk/gtktextdisplay.c: Add warnings if stipple bitmaps
are used on the wrong screen.
* gtk/gtktoolbar.c: Make handling of GtkSettings-based layout
read properties and connect to settings when the screen is changed,
rather than on init/finalize.
* gtk/gtkwindow.c: Fix icon handing to be multihead safe ...
default icon pixmaps/mask are only shared between windows on the
same screen. Misc multihead fixes.
Sat Apr 27 13:49:53 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkclipboard.c (gtk_clipboard_get_for_display):
Update docs to reference GDK_SELECTION_CLIPBOARD rather GDK_NONE.
2002-04-29 Alex Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkproperty-fb.c (gdk_property_get):
Fix silly bug, noticed by Sven Neumann.
Sun Apr 28 22:43:55 2002 Jonathan Blandford <jrb@gnome.org>
* gtk/gtktreemodelsort.c (gtk_tree_model_sort_set_sort_func): Fix
so that you can set a new sort func.
2002-04-29 22:53:45 +00:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (c->gamma_dialog),
|
|
|
|
gtk_widget_get_screen (w));
|
1998-12-18 01:32:33 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (c->gamma_dialog), _("Gamma"));
|
2002-01-29 20:53:17 +00:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (c->gamma_dialog),
|
|
|
|
(gpointer *)&c->gamma_dialog);
|
|
|
|
|
1998-02-18 10:03:54 +00:00
|
|
|
vbox = GTK_DIALOG (c->gamma_dialog)->vbox;
|
|
|
|
|
|
|
|
hbox = gtk_hbox_new (/* homogeneous */ FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2001-11-14 23:59:03 +00:00
|
|
|
label = gtk_label_new_with_mnemonic (_("_Gamma value"));
|
1998-02-18 10:03:54 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
sprintf (buf, "%g", c->gamma);
|
|
|
|
c->gamma_text = gtk_entry_new ();
|
2001-03-24 06:10:40 +00:00
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), c->gamma_text);
|
1998-02-18 10:03:54 +00:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (c->gamma_text), buf);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), c->gamma_text, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (c->gamma_text);
|
|
|
|
|
|
|
|
/* fill in action area: */
|
|
|
|
hbox = GTK_DIALOG (c->gamma_dialog)->action_area;
|
2001-11-02 20:02:44 +00:00
|
|
|
|
2002-02-08 17:35:06 +00:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
2002-10-13 20:44:18 +00:00
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (gamma_cancel_callback), c);
|
2001-11-02 20:02:44 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (button);
|
1998-02-18 10:03:54 +00:00
|
|
|
|
2002-02-08 17:35:06 +00:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_OK);
|
1998-02-18 10:03:54 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
2002-10-13 20:44:18 +00:00
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (gamma_ok_callback), c);
|
1998-02-18 10:03:54 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_grab_default (button);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
gtk_widget_show (c->gamma_dialog);
|
|
|
|
}
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
else
|
1998-02-18 10:03:54 +00:00
|
|
|
{
|
|
|
|
/* reset */
|
|
|
|
gtk_curve_reset (GTK_CURVE (c->curve));
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
curve_type_changed_callback (GtkWidget *w, gpointer data)
|
|
|
|
{
|
|
|
|
GtkGammaCurve *c = data;
|
|
|
|
GtkCurveType new_type;
|
|
|
|
int active;
|
|
|
|
|
|
|
|
new_type = GTK_CURVE (w)->curve_type;
|
|
|
|
switch (new_type)
|
|
|
|
{
|
|
|
|
case GTK_CURVE_TYPE_SPLINE: active = 0; break;
|
|
|
|
case GTK_CURVE_TYPE_LINEAR: active = 1; break;
|
|
|
|
default: active = 2; break;
|
|
|
|
}
|
|
|
|
if (!GTK_TOGGLE_BUTTON (c->button[active])->active)
|
1999-01-11 18:49:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (c->button[active]), TRUE);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
|
|
|
gtk_gamma_curve_new (void)
|
|
|
|
{
|
2002-10-13 20:44:18 +00:00
|
|
|
return g_object_new (GTK_TYPE_GAMMA_CURVE, NULL);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_gamma_curve_destroy (GtkObject *object)
|
|
|
|
{
|
2008-02-07 15:50:39 +00:00
|
|
|
GtkGammaCurve *c = GTK_GAMMA_CURVE (object);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
if (c->gamma_dialog)
|
1998-01-30 23:47:09 +00:00
|
|
|
gtk_widget_destroy (c->gamma_dialog);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2008-08-07 14:12:32 +00:00
|
|
|
GTK_OBJECT_CLASS (gtk_gamma_curve_parent_class)->destroy (object);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
1998-04-09 02:55:46 +00:00
|
|
|
|
2005-03-20 07:01:23 +00:00
|
|
|
#define __GTK_GAMMA_CURVE_C__
|
|
|
|
#include "gtkaliasdef.c"
|