2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2002-11-21 03:45:03 +08:00
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2002-11-23 05:08:04 +08:00
|
|
|
* gimppropwidgets.c
|
2004-04-18 23:12:42 +08:00
|
|
|
* Copyright (C) 2002-2004 Michael Natterer <mitch@gimp.org>
|
|
|
|
* Sven Neumann <sven@gimp.org>
|
2002-11-23 05:08:04 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2002-11-21 03:45:03 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-11-21 03:45:03 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-11-21 03:45:03 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-12-01 22:53:17 +08:00
|
|
|
#include <string.h>
|
2006-09-15 01:11:24 +08:00
|
|
|
#include <stdlib.h>
|
2002-12-01 22:53:17 +08:00
|
|
|
|
2012-03-30 01:19:01 +08:00
|
|
|
#include <gegl.h>
|
2012-03-31 03:22:00 +08:00
|
|
|
#include <gegl-paramspecs.h>
|
2002-11-21 03:45:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-07-27 03:56:47 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2002-11-21 03:45:03 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2002-11-21 03:45:03 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2008-02-05 21:20:11 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2003-02-19 00:52:37 +08:00
|
|
|
#include "core/gimpviewable.h"
|
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
#include "gimpcolorpanel.h"
|
2014-05-26 03:52:39 +08:00
|
|
|
#include "gimpdial.h"
|
2003-02-19 00:52:37 +08:00
|
|
|
#include "gimpdnd.h"
|
2011-03-22 22:20:03 +08:00
|
|
|
#include "gimpiconpicker.h"
|
2009-12-31 05:21:54 +08:00
|
|
|
#include "gimplanguagecombobox.h"
|
2009-08-05 03:26:32 +08:00
|
|
|
#include "gimplanguageentry.h"
|
2008-05-26 23:18:31 +08:00
|
|
|
#include "gimpscalebutton.h"
|
2010-11-02 03:04:35 +08:00
|
|
|
#include "gimpspinscale.h"
|
2004-08-25 01:16:46 +08:00
|
|
|
#include "gimpview.h"
|
2014-05-30 06:33:02 +08:00
|
|
|
#include "gimppolar.h"
|
2002-11-21 03:45:03 +08:00
|
|
|
#include "gimppropwidgets.h"
|
2003-02-08 01:12:21 +08:00
|
|
|
#include "gimpwidgets-constructors.h"
|
2006-10-19 03:54:18 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2002-11-21 03:45:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-11-21 03:45:03 +08:00
|
|
|
|
|
|
|
|
2002-11-23 05:08:04 +08:00
|
|
|
/* utility function prototypes */
|
|
|
|
|
2003-10-24 00:58:16 +08:00
|
|
|
static void set_param_spec (GObject *object,
|
|
|
|
GtkWidget *widget,
|
|
|
|
GParamSpec *param_spec);
|
|
|
|
static GParamSpec * get_param_spec (GObject *object);
|
|
|
|
|
|
|
|
static GParamSpec * find_param_spec (GObject *object,
|
|
|
|
const gchar *property_name,
|
|
|
|
const gchar *strloc);
|
|
|
|
static GParamSpec * check_param_spec (GObject *object,
|
|
|
|
const gchar *property_name,
|
2016-05-09 02:38:46 +08:00
|
|
|
GType type,
|
2003-10-24 00:58:16 +08:00
|
|
|
const gchar *strloc);
|
2007-02-12 19:01:08 +08:00
|
|
|
static GParamSpec * check_param_spec_w (GObject *object,
|
|
|
|
const gchar *property_name,
|
2016-05-09 02:38:46 +08:00
|
|
|
GType type,
|
2007-02-12 19:01:08 +08:00
|
|
|
const gchar *strloc);
|
2003-10-24 00:58:16 +08:00
|
|
|
|
|
|
|
static void connect_notify (GObject *config,
|
|
|
|
const gchar *property_name,
|
|
|
|
GCallback callback,
|
|
|
|
gpointer callback_data);
|
2002-11-23 05:08:04 +08:00
|
|
|
|
|
|
|
|
2006-10-19 03:54:18 +08:00
|
|
|
/*********************/
|
|
|
|
/* expanding frame */
|
|
|
|
/*********************/
|
|
|
|
|
2016-02-11 23:35:45 +08:00
|
|
|
/**
|
|
|
|
* gimp_prop_expanding_frame_new:
|
|
|
|
* @config: #GimpConfig object to which property is attached.
|
|
|
|
* @property_name: Name of boolean property.
|
|
|
|
* @button_label: Toggle widget title appearing as a frame title.
|
|
|
|
* @child: Child #GtkWidget of the returned frame.
|
|
|
|
* @button: Pointer to the #GtkCheckButton used as frame title
|
|
|
|
* if not #NULL.
|
|
|
|
*
|
|
|
|
* Creates a #GimpFrame containing @child, using a #GtkCheckButton as a
|
|
|
|
* title whose value is tied to the boolean @property_name.
|
|
|
|
* @child will be visible when @property_name is #TRUE, hidden otherwise.
|
|
|
|
* If @button_label is #NULL, the @property_name's nick will be used as
|
|
|
|
* label of the #GtkCheckButton title.
|
|
|
|
*
|
|
|
|
* Return value: A new #GimpFrame widget.
|
|
|
|
*
|
|
|
|
* Since GIMP 2.4
|
|
|
|
*/
|
2006-10-19 03:54:18 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_expanding_frame_new (GObject *config,
|
|
|
|
const gchar *property_name,
|
|
|
|
const gchar *button_label,
|
|
|
|
GtkWidget *child,
|
|
|
|
GtkWidget **button)
|
|
|
|
{
|
2016-02-10 06:35:06 +08:00
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *toggle;
|
|
|
|
gboolean value;
|
2006-10-19 03:54:18 +08:00
|
|
|
|
2016-02-10 06:35:06 +08:00
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_BOOLEAN, G_STRFUNC);
|
|
|
|
if (! param_spec)
|
2006-10-19 03:54:18 +08:00
|
|
|
return NULL;
|
|
|
|
|
2016-02-10 06:35:06 +08:00
|
|
|
if (! button_label)
|
|
|
|
button_label = g_param_spec_get_nick (param_spec);
|
|
|
|
|
2006-10-19 03:54:18 +08:00
|
|
|
frame = gimp_frame_new (NULL);
|
|
|
|
|
|
|
|
toggle = gimp_prop_check_button_new (config, property_name, button_label);
|
|
|
|
gtk_frame_set_label_widget (GTK_FRAME (frame), toggle);
|
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), child);
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
property_name, &value,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
gtk_widget_show (child);
|
|
|
|
|
|
|
|
g_signal_connect_object (toggle, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_set_visible),
|
|
|
|
child, 0);
|
|
|
|
|
|
|
|
if (button)
|
|
|
|
*button = toggle;
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-05 04:47:42 +08:00
|
|
|
/****************/
|
|
|
|
/* paint menu */
|
|
|
|
/****************/
|
2004-04-19 07:48:30 +08:00
|
|
|
|
|
|
|
static void gimp_prop_paint_menu_callback (GtkWidget *widget,
|
2005-02-05 04:47:42 +08:00
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_paint_menu_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *menu);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-02-04 06:31:55 +08:00
|
|
|
/**
|
2005-02-05 04:47:42 +08:00
|
|
|
* gimp_prop_paint_mode_menu_new:
|
2006-10-22 02:46:49 +08:00
|
|
|
* @config: #GimpConfig object to which property is attached.
|
|
|
|
* @property_name: Name of Enum property.
|
|
|
|
* @with_behind_mode: Whether to include "Behind" mode in the menu.
|
|
|
|
* @with_replace_modes: Whether to include the "Replace", "Erase" and
|
|
|
|
* "Anti Erase" modes in the menu.
|
2005-02-04 06:31:55 +08:00
|
|
|
*
|
2005-02-05 04:47:42 +08:00
|
|
|
* Creates a #GimpPaintModeMenu widget to display and set the specified
|
|
|
|
* Enum property, for which the enum must be #GimpLayerModeEffects.
|
2005-02-04 06:31:55 +08:00
|
|
|
*
|
2005-02-05 04:47:42 +08:00
|
|
|
* Return value: The newly created #GimpPaintModeMenu widget.
|
2005-02-04 06:31:55 +08:00
|
|
|
*
|
|
|
|
* Since GIMP 2.4
|
|
|
|
*/
|
2003-07-07 21:37:19 +08:00
|
|
|
GtkWidget *
|
2005-02-05 04:47:42 +08:00
|
|
|
gimp_prop_paint_mode_menu_new (GObject *config,
|
|
|
|
const gchar *property_name,
|
2006-10-22 02:46:49 +08:00
|
|
|
gboolean with_behind_mode,
|
|
|
|
gboolean with_replace_modes)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
2005-02-05 04:47:42 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
gint value;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2007-02-12 19:01:08 +08:00
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_ENUM, G_STRFUNC);
|
2003-07-07 21:37:19 +08:00
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
property_name, &value,
|
|
|
|
NULL);
|
|
|
|
|
2006-10-22 02:46:49 +08:00
|
|
|
menu = gimp_paint_mode_menu_new (with_behind_mode, with_replace_modes);
|
2005-02-09 04:07:08 +08:00
|
|
|
|
|
|
|
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (menu),
|
|
|
|
value,
|
|
|
|
G_CALLBACK (gimp_prop_paint_menu_callback),
|
|
|
|
config);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-02-05 04:47:42 +08:00
|
|
|
set_param_spec (G_OBJECT (menu), menu, param_spec);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
2005-02-05 04:47:42 +08:00
|
|
|
G_CALLBACK (gimp_prop_paint_menu_notify),
|
|
|
|
menu);
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-02-05 04:47:42 +08:00
|
|
|
return menu;
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-02-05 04:47:42 +08:00
|
|
|
gimp_prop_paint_menu_callback (GtkWidget *widget,
|
2003-07-07 21:37:19 +08:00
|
|
|
GObject *config)
|
|
|
|
{
|
2005-02-09 04:07:08 +08:00
|
|
|
GParamSpec *param_spec;
|
|
|
|
gint value;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-02-09 04:07:08 +08:00
|
|
|
param_spec = get_param_spec (G_OBJECT (widget));
|
|
|
|
if (! param_spec)
|
|
|
|
return;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
2005-02-09 04:07:08 +08:00
|
|
|
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
|
|
|
|
{
|
|
|
|
g_object_set (config,
|
|
|
|
param_spec->name, value,
|
|
|
|
NULL);
|
2005-02-05 04:47:42 +08:00
|
|
|
}
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-02-05 04:47:42 +08:00
|
|
|
gimp_prop_paint_menu_notify (GObject *config,
|
2003-07-07 21:37:19 +08:00
|
|
|
GParamSpec *param_spec,
|
2005-02-05 04:47:42 +08:00
|
|
|
GtkWidget *menu)
|
2003-07-07 21:37:19 +08:00
|
|
|
{
|
2005-02-05 04:47:42 +08:00
|
|
|
gint value;
|
2003-07-07 21:37:19 +08:00
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &value,
|
|
|
|
NULL);
|
|
|
|
|
2005-02-09 04:07:08 +08:00
|
|
|
g_signal_handlers_block_by_func (menu,
|
|
|
|
gimp_prop_paint_menu_callback,
|
|
|
|
config);
|
|
|
|
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (menu), value);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (menu,
|
|
|
|
gimp_prop_paint_menu_callback,
|
|
|
|
config);
|
|
|
|
|
2003-07-07 21:37:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
/******************/
|
|
|
|
/* color button */
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
static void gimp_prop_color_button_callback (GtkWidget *widget,
|
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_color_button_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *button);
|
|
|
|
|
2005-02-04 06:31:55 +08:00
|
|
|
/**
|
|
|
|
* gimp_prop_color_button_new:
|
2006-08-04 17:41:09 +08:00
|
|
|
* @config: #GimpConfig object to which property is attached.
|
|
|
|
* @property_name: Name of #GimpRGB property.
|
|
|
|
* @title: Title of the #GimpColorPanel that is to be created
|
|
|
|
* @width: Width of color button.
|
|
|
|
* @height: Height of color button.
|
|
|
|
* @type: How transparency is represented.
|
2005-02-04 06:31:55 +08:00
|
|
|
*
|
2006-08-04 17:41:09 +08:00
|
|
|
* Creates a #GimpColorPanel to set and display the value of a #GimpRGB
|
2005-02-04 06:31:55 +08:00
|
|
|
* property. Pressing the button brings up a color selector dialog.
|
2016-02-11 23:35:45 +08:00
|
|
|
* If @title is #NULL, the @property_name's nick will be used as label
|
|
|
|
* of the returned widget.
|
2005-02-04 06:31:55 +08:00
|
|
|
*
|
|
|
|
* Return value: A new #GimpColorPanel widget.
|
|
|
|
*
|
|
|
|
* Since GIMP 2.4
|
|
|
|
*/
|
2002-11-24 06:22:21 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_color_button_new (GObject *config,
|
|
|
|
const gchar *property_name,
|
|
|
|
const gchar *title,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpColorAreaType type)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkWidget *button;
|
|
|
|
GimpRGB *value;
|
|
|
|
|
2007-02-12 19:01:08 +08:00
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
GIMP_TYPE_PARAM_RGB, G_STRFUNC);
|
2002-11-24 06:22:21 +08:00
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
2016-02-10 06:35:06 +08:00
|
|
|
if (! title)
|
|
|
|
title = g_param_spec_get_nick (param_spec);
|
|
|
|
|
2002-11-24 06:22:21 +08:00
|
|
|
g_object_get (config,
|
|
|
|
property_name, &value,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
button = gimp_color_panel_new (title, value, type, width, height);
|
|
|
|
g_free (value);
|
|
|
|
|
2003-01-26 04:29:42 +08:00
|
|
|
set_param_spec (G_OBJECT (button), button, param_spec);
|
2002-11-24 06:22:21 +08:00
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (button, "color-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_CALLBACK (gimp_prop_color_button_callback),
|
|
|
|
config);
|
2002-11-24 06:22:21 +08:00
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
|
|
|
G_CALLBACK (gimp_prop_color_button_notify),
|
|
|
|
button);
|
|
|
|
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_color_button_callback (GtkWidget *button,
|
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GimpRGB value;
|
|
|
|
|
|
|
|
param_spec = get_param_spec (G_OBJECT (button));
|
|
|
|
if (! param_spec)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &value);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (config,
|
|
|
|
gimp_prop_color_button_notify,
|
|
|
|
button);
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
param_spec->name, &value,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (config,
|
|
|
|
gimp_prop_color_button_notify,
|
|
|
|
button);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_color_button_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *button)
|
|
|
|
{
|
|
|
|
GimpRGB *value;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &value,
|
|
|
|
NULL);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_block_by_func (button,
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_prop_color_button_callback,
|
|
|
|
config);
|
|
|
|
|
|
|
|
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), value);
|
|
|
|
|
|
|
|
g_free (value);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_unblock_by_func (button,
|
2002-11-24 06:22:21 +08:00
|
|
|
gimp_prop_color_button_callback,
|
|
|
|
config);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-26 23:18:31 +08:00
|
|
|
/******************/
|
|
|
|
/* scale button */
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
static void gimp_prop_scale_button_callback (GtkWidget *widget,
|
2008-05-26 23:27:24 +08:00
|
|
|
gdouble value,
|
2008-05-26 23:18:31 +08:00
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_scale_button_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *button);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_prop_scale_button_new:
|
|
|
|
* @config: #GimpConfig object to which property is attached.
|
|
|
|
* @property_name: Name of gdouble property
|
|
|
|
*
|
|
|
|
* Creates a #GimpScaleButton to set and display the value of a
|
|
|
|
* gdouble property in a very space-efficient way.
|
|
|
|
*
|
|
|
|
* Return value: A new #GimpScaleButton widget.
|
|
|
|
*
|
|
|
|
* Since GIMP 2.6
|
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_scale_button_new (GObject *config,
|
|
|
|
const gchar *property_name)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkWidget *button;
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_DOUBLE, G_STRFUNC);
|
|
|
|
|
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &value,
|
|
|
|
NULL);
|
|
|
|
|
2008-05-27 00:41:34 +08:00
|
|
|
button = gimp_scale_button_new (value,
|
|
|
|
G_PARAM_SPEC_DOUBLE (param_spec)->minimum,
|
|
|
|
G_PARAM_SPEC_DOUBLE (param_spec)->maximum);
|
2008-05-26 23:18:31 +08:00
|
|
|
|
|
|
|
set_param_spec (G_OBJECT (button), button, param_spec);
|
|
|
|
|
|
|
|
g_signal_connect (button, "value-changed",
|
|
|
|
G_CALLBACK (gimp_prop_scale_button_callback),
|
|
|
|
config);
|
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
|
|
|
G_CALLBACK (gimp_prop_scale_button_notify),
|
|
|
|
button);
|
|
|
|
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_scale_button_callback (GtkWidget *button,
|
2008-05-26 23:27:24 +08:00
|
|
|
gdouble value,
|
2008-05-26 23:18:31 +08:00
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
|
|
|
|
param_spec = get_param_spec (G_OBJECT (button));
|
|
|
|
if (! param_spec)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (config,
|
|
|
|
gimp_prop_scale_button_notify,
|
|
|
|
button);
|
|
|
|
|
|
|
|
g_object_set (config,
|
2008-05-26 23:27:24 +08:00
|
|
|
param_spec->name, value,
|
2008-05-26 23:18:31 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (config,
|
|
|
|
gimp_prop_scale_button_notify,
|
|
|
|
button);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_scale_button_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *button)
|
|
|
|
{
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &value,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (button,
|
|
|
|
gimp_prop_scale_button_callback,
|
|
|
|
config);
|
|
|
|
|
2009-03-23 02:12:36 +08:00
|
|
|
gtk_scale_button_set_value (GTK_SCALE_BUTTON (button), value);
|
2008-05-26 23:18:31 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (button,
|
|
|
|
gimp_prop_scale_button_callback,
|
|
|
|
config);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
/*****************/
|
|
|
|
/* adjustments */
|
|
|
|
/*****************/
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
static void gimp_prop_adjustment_callback (GtkAdjustment *adjustment,
|
2010-11-02 03:04:35 +08:00
|
|
|
GObject *config);
|
2010-11-02 04:48:19 +08:00
|
|
|
static void gimp_prop_adjustment_notify (GObject *config,
|
2010-11-02 03:04:35 +08:00
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkAdjustment *adjustment);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_prop_spin_scale_new:
|
|
|
|
* @config: #GimpConfig object to which property is attached.
|
|
|
|
* @property_name: Name of gdouble property
|
2016-02-11 23:35:45 +08:00
|
|
|
* @label: Label of the created #GimpSpinScale.
|
|
|
|
* @step_increment:
|
|
|
|
* @page_increment:
|
|
|
|
* @digits:
|
2010-11-02 03:04:35 +08:00
|
|
|
*
|
|
|
|
* Creates a #GimpSpinScale to set and display the value of a
|
|
|
|
* gdouble property in a very space-efficient way.
|
2016-02-11 23:35:45 +08:00
|
|
|
* If @label is #NULL, the @property_name's nick will be used as label
|
|
|
|
* of the returned widget.
|
2010-11-02 03:04:35 +08:00
|
|
|
*
|
|
|
|
* Return value: A new #GimpSpinScale widget.
|
|
|
|
*
|
|
|
|
* Since GIMP 2.8
|
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_spin_scale_new (GObject *config,
|
|
|
|
const gchar *property_name,
|
|
|
|
const gchar *label,
|
|
|
|
gdouble step_increment,
|
|
|
|
gdouble page_increment,
|
|
|
|
gint digits)
|
|
|
|
{
|
2014-07-21 08:34:39 +08:00
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
GtkWidget *scale;
|
|
|
|
gdouble value;
|
|
|
|
gdouble lower;
|
|
|
|
gdouble upper;
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
param_spec = find_param_spec (config, property_name, G_STRFUNC);
|
2010-11-02 03:04:35 +08:00
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
if (! _gimp_prop_widgets_get_numeric_values (config, param_spec,
|
|
|
|
&value, &lower, &upper,
|
|
|
|
G_STRFUNC))
|
2010-11-02 04:48:19 +08:00
|
|
|
return NULL;
|
|
|
|
|
2014-06-02 05:39:19 +08:00
|
|
|
if (! label)
|
|
|
|
label = g_param_spec_get_nick (param_spec);
|
|
|
|
|
2016-02-10 06:35:06 +08:00
|
|
|
if (! G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
|
|
|
digits = 0;
|
|
|
|
|
2014-07-21 08:34:39 +08:00
|
|
|
adjustment = (GtkAdjustment *)
|
|
|
|
gtk_adjustment_new (value, lower, upper,
|
|
|
|
step_increment, page_increment, 0.0);
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2014-07-21 08:34:39 +08:00
|
|
|
scale = gimp_spin_scale_new (adjustment, label, digits);
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2010-11-02 03:54:43 +08:00
|
|
|
set_param_spec (G_OBJECT (adjustment), scale, param_spec);
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2012-03-31 03:22:00 +08:00
|
|
|
if (GEGL_IS_PARAM_SPEC_DOUBLE (param_spec))
|
|
|
|
{
|
|
|
|
GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (param_spec);
|
2014-05-21 02:47:31 +08:00
|
|
|
|
2012-03-31 04:38:47 +08:00
|
|
|
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale),
|
|
|
|
gspec->ui_minimum, gspec->ui_maximum);
|
|
|
|
gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), gspec->ui_gamma);
|
2012-03-31 03:22:00 +08:00
|
|
|
}
|
2013-05-20 05:23:32 +08:00
|
|
|
else if (GEGL_IS_PARAM_SPEC_INT (param_spec))
|
2012-03-31 03:22:00 +08:00
|
|
|
{
|
|
|
|
GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (param_spec);
|
2014-05-21 02:47:31 +08:00
|
|
|
|
2012-03-31 04:38:47 +08:00
|
|
|
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale),
|
|
|
|
gspec->ui_minimum, gspec->ui_maximum);
|
|
|
|
gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), gspec->ui_gamma);
|
2012-03-31 03:22:00 +08:00
|
|
|
}
|
|
|
|
|
2010-11-02 03:04:35 +08:00
|
|
|
g_signal_connect (adjustment, "value-changed",
|
2010-11-02 04:48:19 +08:00
|
|
|
G_CALLBACK (gimp_prop_adjustment_callback),
|
2010-11-02 03:04:35 +08:00
|
|
|
config);
|
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
2010-11-02 04:48:19 +08:00
|
|
|
G_CALLBACK (gimp_prop_adjustment_notify),
|
2010-11-02 03:04:35 +08:00
|
|
|
adjustment);
|
|
|
|
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
void
|
|
|
|
gimp_prop_widget_set_factor (GtkWidget *widget,
|
|
|
|
gdouble factor,
|
2014-02-04 05:57:51 +08:00
|
|
|
gdouble step_increment,
|
|
|
|
gdouble page_increment,
|
2013-06-15 07:28:54 +08:00
|
|
|
gint digits)
|
2010-11-02 05:07:39 +08:00
|
|
|
{
|
2013-06-15 07:28:54 +08:00
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
gdouble *factor_store;
|
|
|
|
gdouble old_factor = 1.0;
|
|
|
|
gdouble f;
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
g_return_if_fail (GTK_IS_SPIN_BUTTON (widget));
|
|
|
|
g_return_if_fail (factor != 0.0);
|
|
|
|
g_return_if_fail (digits >= 0);
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
g_return_if_fail (get_param_spec (G_OBJECT (adjustment)) != NULL);
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
factor_store = g_object_get_data (G_OBJECT (adjustment),
|
|
|
|
"gimp-prop-adjustment-factor");
|
|
|
|
if (factor_store)
|
|
|
|
{
|
|
|
|
old_factor = *factor_store;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
factor_store = g_new (gdouble, 1);
|
|
|
|
g_object_set_data_full (G_OBJECT (adjustment),
|
|
|
|
"gimp-prop-adjustment-factor",
|
|
|
|
factor_store, (GDestroyNotify) g_free);
|
|
|
|
}
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
*factor_store = factor;
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
f = factor / old_factor;
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2014-02-04 05:57:51 +08:00
|
|
|
if (step_increment <= 0)
|
|
|
|
step_increment = f * gtk_adjustment_get_step_increment (adjustment);
|
|
|
|
|
|
|
|
if (page_increment <= 0)
|
|
|
|
page_increment = f * gtk_adjustment_get_page_increment (adjustment);
|
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
gtk_adjustment_configure (adjustment,
|
|
|
|
f * gtk_adjustment_get_value (adjustment),
|
|
|
|
f * gtk_adjustment_get_lower (adjustment),
|
|
|
|
f * gtk_adjustment_get_upper (adjustment),
|
2014-02-04 05:57:51 +08:00
|
|
|
step_increment,
|
|
|
|
page_increment,
|
2013-06-15 07:28:54 +08:00
|
|
|
f * gtk_adjustment_get_page_size (adjustment));
|
2010-11-02 05:07:39 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), digits);
|
2010-11-02 05:07:39 +08:00
|
|
|
}
|
|
|
|
|
2010-11-02 03:04:35 +08:00
|
|
|
static void
|
2010-11-02 04:48:19 +08:00
|
|
|
gimp_prop_adjustment_callback (GtkAdjustment *adjustment,
|
2010-11-02 03:04:35 +08:00
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
2010-11-02 04:48:19 +08:00
|
|
|
gdouble value;
|
2013-06-15 07:28:54 +08:00
|
|
|
gdouble *factor;
|
2010-11-02 03:04:35 +08:00
|
|
|
|
|
|
|
param_spec = get_param_spec (G_OBJECT (adjustment));
|
|
|
|
if (! param_spec)
|
|
|
|
return;
|
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
value = gtk_adjustment_get_value (adjustment);
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
factor = g_object_get_data (G_OBJECT (adjustment),
|
|
|
|
"gimp-prop-adjustment-factor");
|
|
|
|
if (factor)
|
|
|
|
value /= *factor;
|
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
if (G_IS_PARAM_SPEC_INT (param_spec))
|
|
|
|
{
|
2014-06-19 08:01:10 +08:00
|
|
|
gint v;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &v, NULL);
|
|
|
|
|
|
|
|
if (v != (gint) value)
|
|
|
|
g_object_set (config, param_spec->name, (gint) value, NULL);
|
2010-11-02 04:48:19 +08:00
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_UINT (param_spec))
|
|
|
|
{
|
2014-06-19 08:01:10 +08:00
|
|
|
guint v;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &v, NULL);
|
|
|
|
|
|
|
|
if (v != (guint) value)
|
|
|
|
g_object_set (config, param_spec->name, (guint) value, NULL);
|
2010-11-02 04:48:19 +08:00
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_LONG (param_spec))
|
|
|
|
{
|
2014-06-19 08:01:10 +08:00
|
|
|
glong v;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &v, NULL);
|
|
|
|
|
|
|
|
if (v != (glong) value)
|
|
|
|
g_object_set (config, param_spec->name, (glong) value, NULL);
|
2010-11-02 04:48:19 +08:00
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_ULONG (param_spec))
|
|
|
|
{
|
2014-06-19 08:01:10 +08:00
|
|
|
gulong v;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &v, NULL);
|
|
|
|
|
|
|
|
if (v != (gulong) value)
|
|
|
|
g_object_set (config, param_spec->name, (gulong) value, NULL);
|
2010-11-02 04:48:19 +08:00
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_INT64 (param_spec))
|
|
|
|
{
|
2014-06-19 08:01:10 +08:00
|
|
|
gint64 v;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &v, NULL);
|
|
|
|
|
|
|
|
if (v != (gint64) value)
|
|
|
|
g_object_set (config, param_spec->name, (gint64) value, NULL);
|
2010-11-02 04:48:19 +08:00
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_UINT64 (param_spec))
|
|
|
|
{
|
2014-06-19 08:01:10 +08:00
|
|
|
guint64 v;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &v, NULL);
|
|
|
|
|
|
|
|
if (v != (guint64) value)
|
|
|
|
g_object_set (config, param_spec->name, (guint64) value, NULL);
|
2010-11-02 04:48:19 +08:00
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
|
|
|
{
|
2014-06-19 08:01:10 +08:00
|
|
|
gdouble v;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &v, NULL);
|
|
|
|
|
|
|
|
if (v != value)
|
|
|
|
g_object_set (config, param_spec->name, value, NULL);
|
2010-11-02 04:48:19 +08:00
|
|
|
}
|
2010-11-02 03:04:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-02 04:48:19 +08:00
|
|
|
gimp_prop_adjustment_notify (GObject *config,
|
2010-11-02 03:04:35 +08:00
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkAdjustment *adjustment)
|
|
|
|
{
|
2013-06-15 07:28:54 +08:00
|
|
|
gdouble value;
|
|
|
|
gdouble *factor;
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
if (G_IS_PARAM_SPEC_INT (param_spec))
|
|
|
|
{
|
|
|
|
gint int_value;
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
g_object_get (config, param_spec->name, &int_value, NULL);
|
|
|
|
|
|
|
|
value = int_value;
|
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_UINT (param_spec))
|
|
|
|
{
|
|
|
|
guint uint_value;
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
g_object_get (config, param_spec->name, &uint_value, NULL);
|
2010-11-02 03:04:35 +08:00
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
value = uint_value;
|
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_LONG (param_spec))
|
|
|
|
{
|
|
|
|
glong long_value;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &long_value, NULL);
|
|
|
|
|
|
|
|
value = long_value;
|
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_ULONG (param_spec))
|
|
|
|
{
|
|
|
|
gulong ulong_value;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &ulong_value, NULL);
|
|
|
|
|
|
|
|
value = ulong_value;
|
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_INT64 (param_spec))
|
|
|
|
{
|
|
|
|
gint64 int64_value;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &int64_value, NULL);
|
|
|
|
|
|
|
|
value = int64_value;
|
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_UINT64 (param_spec))
|
|
|
|
{
|
|
|
|
guint64 uint64_value;
|
|
|
|
|
|
|
|
g_object_get (config, param_spec->name, &uint64_value, NULL);
|
|
|
|
|
|
|
|
#if defined _MSC_VER && (_MSC_VER < 1300)
|
|
|
|
value = (gint64) uint64_value;
|
|
|
|
#else
|
|
|
|
value = uint64_value;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
|
|
|
{
|
|
|
|
g_object_get (config, param_spec->name, &value, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("%s: unhandled param spec of type %s",
|
|
|
|
G_STRFUNC, G_PARAM_SPEC_TYPE_NAME (param_spec));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-15 07:28:54 +08:00
|
|
|
factor = g_object_get_data (G_OBJECT (adjustment),
|
|
|
|
"gimp-prop-adjustment-factor");
|
|
|
|
if (factor)
|
|
|
|
value *= *factor;
|
|
|
|
|
2010-11-02 04:48:19 +08:00
|
|
|
if (gtk_adjustment_get_value (adjustment) != value)
|
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (adjustment,
|
|
|
|
gimp_prop_adjustment_callback,
|
|
|
|
config);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (adjustment, value);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (adjustment,
|
|
|
|
gimp_prop_adjustment_callback,
|
|
|
|
config);
|
|
|
|
}
|
2010-11-02 03:04:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-26 03:52:39 +08:00
|
|
|
/************/
|
|
|
|
/* angles */
|
|
|
|
/************/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
deg_to_rad (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue *to_value,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gdouble *lower = user_data;
|
|
|
|
gdouble value = g_value_get_double (from_value);
|
|
|
|
|
2014-05-28 06:59:44 +08:00
|
|
|
if (lower && *lower != 0.0)
|
2014-05-26 03:52:39 +08:00
|
|
|
{
|
|
|
|
if (value < 0.0)
|
|
|
|
value += 360.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
value *= G_PI / 180.0;
|
|
|
|
|
|
|
|
g_value_set_double (to_value, value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
rad_to_deg (GBinding *binding,
|
|
|
|
const GValue *from_value,
|
|
|
|
GValue *to_value,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gdouble *lower = user_data;
|
|
|
|
gdouble value = g_value_get_double (from_value);
|
|
|
|
|
|
|
|
value *= 180.0 / G_PI;
|
|
|
|
|
2014-05-28 06:59:44 +08:00
|
|
|
if (lower && *lower != 0.0)
|
2014-05-26 03:52:39 +08:00
|
|
|
{
|
|
|
|
if (value > (*lower + 360.0))
|
|
|
|
value -= 360.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_set_double (to_value, value);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_prop_angle_dial_new:
|
|
|
|
* @config: #GimpConfig object to which property is attached.
|
|
|
|
* @property_name: Name of gdouble property
|
|
|
|
*
|
|
|
|
* Creates a #GimpDial to set and display the value of a
|
|
|
|
* gdouble property that represents an angle.
|
|
|
|
*
|
|
|
|
* Return value: A new #GimpDial widget.
|
|
|
|
*
|
|
|
|
* Since GIMP 2.10
|
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_angle_dial_new (GObject *config,
|
|
|
|
const gchar *property_name)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkWidget *dial;
|
|
|
|
gdouble value;
|
|
|
|
gdouble lower;
|
|
|
|
gdouble upper;
|
|
|
|
|
|
|
|
param_spec = find_param_spec (config, property_name, G_STRFUNC);
|
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (! _gimp_prop_widgets_get_numeric_values (config, param_spec,
|
|
|
|
&value, &lower, &upper,
|
|
|
|
G_STRFUNC))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dial = gimp_dial_new ();
|
|
|
|
|
|
|
|
g_object_set (dial,
|
2014-05-30 06:33:02 +08:00
|
|
|
"size", 32,
|
|
|
|
"background", GIMP_CIRCLE_BACKGROUND_PLAIN,
|
|
|
|
"draw-beta", FALSE,
|
2014-05-26 03:52:39 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
set_param_spec (G_OBJECT (dial), dial, param_spec);
|
|
|
|
|
|
|
|
if (lower == 0.0 && upper == 2 * G_PI)
|
|
|
|
{
|
|
|
|
g_object_bind_property (config, property_name,
|
|
|
|
dial, "alpha",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
}
|
|
|
|
else if ((upper - lower) == 360.0)
|
|
|
|
{
|
|
|
|
gdouble *l = g_new0 (gdouble, 1);
|
|
|
|
|
|
|
|
*l = lower;
|
|
|
|
|
|
|
|
g_object_bind_property_full (config, property_name,
|
|
|
|
dial, "alpha",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE,
|
|
|
|
deg_to_rad,
|
|
|
|
rad_to_deg,
|
|
|
|
l, (GDestroyNotify) g_free);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dial;
|
|
|
|
}
|
|
|
|
|
2014-05-28 06:59:44 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_angle_range_dial_new (GObject *config,
|
|
|
|
const gchar *alpha_property_name,
|
|
|
|
const gchar *beta_property_name,
|
|
|
|
const gchar *clockwise_property_name)
|
|
|
|
{
|
|
|
|
GParamSpec *alpha_param_spec;
|
|
|
|
GParamSpec *beta_param_spec;
|
|
|
|
GParamSpec *clockwise_param_spec;
|
|
|
|
GtkWidget *dial;
|
|
|
|
|
|
|
|
alpha_param_spec = find_param_spec (config, alpha_property_name, G_STRFUNC);
|
|
|
|
if (! alpha_param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
beta_param_spec = find_param_spec (config, beta_property_name, G_STRFUNC);
|
|
|
|
if (! beta_param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
clockwise_param_spec = find_param_spec (config, clockwise_property_name, G_STRFUNC);
|
|
|
|
if (! clockwise_param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
dial = gimp_dial_new ();
|
|
|
|
|
|
|
|
g_object_set (dial,
|
|
|
|
"size", 96,
|
|
|
|
"border-width", 0,
|
|
|
|
"background", GIMP_CIRCLE_BACKGROUND_HSV,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_object_bind_property_full (config, alpha_property_name,
|
|
|
|
dial, "alpha",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE,
|
|
|
|
deg_to_rad,
|
|
|
|
rad_to_deg,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
g_object_bind_property_full (config, beta_property_name,
|
|
|
|
dial, "beta",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE,
|
|
|
|
deg_to_rad,
|
|
|
|
rad_to_deg,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
g_object_bind_property (config, clockwise_property_name,
|
|
|
|
dial, "clockwise",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
|
|
|
|
return dial;
|
|
|
|
}
|
|
|
|
|
2014-05-30 06:33:02 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_polar_new (GObject *config,
|
|
|
|
const gchar *angle_property_name,
|
|
|
|
const gchar *radius_property_name)
|
|
|
|
{
|
|
|
|
GParamSpec *angle_param_spec;
|
|
|
|
GParamSpec *radius_param_spec;
|
|
|
|
GtkWidget *polar;
|
|
|
|
|
|
|
|
angle_param_spec = find_param_spec (config, angle_property_name, G_STRFUNC);
|
|
|
|
if (! angle_param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
radius_param_spec = find_param_spec (config, radius_property_name, G_STRFUNC);
|
|
|
|
if (! radius_param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
polar = gimp_polar_new ();
|
|
|
|
|
|
|
|
g_object_set (polar,
|
|
|
|
"size", 90,
|
|
|
|
"border-width", 3,
|
|
|
|
"background", GIMP_CIRCLE_BACKGROUND_HSV,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_object_bind_property_full (config, angle_property_name,
|
|
|
|
polar, "angle",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE,
|
|
|
|
deg_to_rad,
|
|
|
|
rad_to_deg,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
g_object_bind_property (config, radius_property_name,
|
|
|
|
polar, "radius",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE);
|
|
|
|
|
|
|
|
return polar;
|
|
|
|
}
|
|
|
|
|
2014-05-26 03:52:39 +08:00
|
|
|
|
|
|
|
/**********/
|
2006-01-17 18:08:50 +08:00
|
|
|
/* view */
|
2014-05-26 03:52:39 +08:00
|
|
|
/**********/
|
2003-02-19 00:52:37 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
static void gimp_prop_view_drop (GtkWidget *menu,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_prop_view_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *view);
|
2003-02-19 00:52:37 +08:00
|
|
|
|
2005-02-04 06:31:55 +08:00
|
|
|
/**
|
2006-01-17 18:08:50 +08:00
|
|
|
* gimp_prop_view_new:
|
2006-08-04 17:41:09 +08:00
|
|
|
* @config: #GimpConfig object to which property is attached.
|
2006-08-30 05:44:51 +08:00
|
|
|
* @context: a #Gimpcontext.
|
2006-08-04 17:41:09 +08:00
|
|
|
* @property_name: Name of #GimpViewable property.
|
|
|
|
* @size: Width and height of preview display.
|
2005-02-04 06:31:55 +08:00
|
|
|
*
|
2006-08-04 17:41:09 +08:00
|
|
|
* Creates a widget to display the value of a #GimpViewable property.
|
2005-02-04 06:31:55 +08:00
|
|
|
*
|
|
|
|
* Return value: A new #GimpView widget.
|
|
|
|
*
|
|
|
|
* Since GIMP 2.4
|
|
|
|
*/
|
2003-02-19 00:52:37 +08:00
|
|
|
GtkWidget *
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_prop_view_new (GObject *config,
|
|
|
|
const gchar *property_name,
|
2006-08-30 05:44:51 +08:00
|
|
|
GimpContext *context,
|
2006-01-17 18:08:50 +08:00
|
|
|
gint size)
|
2003-02-19 00:52:37 +08:00
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
2006-01-17 18:08:50 +08:00
|
|
|
GtkWidget *view;
|
2003-02-19 00:52:37 +08:00
|
|
|
GimpViewable *viewable;
|
|
|
|
|
2007-02-12 19:01:08 +08:00
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_OBJECT, G_STRFUNC);
|
2003-02-19 00:52:37 +08:00
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (! g_type_is_a (param_spec->value_type, GIMP_TYPE_VIEWABLE))
|
|
|
|
{
|
|
|
|
g_warning ("%s: property '%s' of %s is not a GimpViewable",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, property_name,
|
2003-02-19 00:52:37 +08:00
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (config)));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-30 05:44:51 +08:00
|
|
|
view = gimp_view_new_by_types (context,
|
|
|
|
GIMP_TYPE_VIEW,
|
2006-01-17 18:08:50 +08:00
|
|
|
param_spec->value_type,
|
|
|
|
size, 0, FALSE);
|
2003-02-19 00:52:37 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
if (! view)
|
2003-02-19 00:52:37 +08:00
|
|
|
{
|
2006-01-17 18:08:50 +08:00
|
|
|
g_warning ("%s: cannot create view for type '%s'",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC, g_type_name (param_spec->value_type));
|
2003-02-19 00:52:37 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
property_name, &viewable,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (viewable)
|
|
|
|
{
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_view_set_viewable (GIMP_VIEW (view), viewable);
|
2003-02-19 00:52:37 +08:00
|
|
|
g_object_unref (viewable);
|
|
|
|
}
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
set_param_spec (G_OBJECT (view), view, param_spec);
|
2003-02-19 00:52:37 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_dnd_viewable_dest_add (view, param_spec->value_type,
|
|
|
|
gimp_prop_view_drop,
|
2003-02-19 00:52:37 +08:00
|
|
|
config);
|
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
2006-01-17 18:08:50 +08:00
|
|
|
G_CALLBACK (gimp_prop_view_notify),
|
|
|
|
view);
|
2003-02-19 00:52:37 +08:00
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
return view;
|
2003-02-19 00:52:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_prop_view_drop (GtkWidget *view,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
2003-02-19 00:52:37 +08:00
|
|
|
{
|
|
|
|
GObject *config;
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
param_spec = get_param_spec (G_OBJECT (view));
|
2003-02-19 00:52:37 +08:00
|
|
|
if (! param_spec)
|
|
|
|
return;
|
|
|
|
|
|
|
|
config = G_OBJECT (data);
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
param_spec->name, viewable,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_prop_view_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *view)
|
2003-02-19 00:52:37 +08:00
|
|
|
{
|
|
|
|
GimpViewable *viewable;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &viewable,
|
|
|
|
NULL);
|
|
|
|
|
2006-01-17 18:08:50 +08:00
|
|
|
gimp_view_set_viewable (GIMP_VIEW (view), viewable);
|
2003-02-19 00:52:37 +08:00
|
|
|
|
|
|
|
if (viewable)
|
|
|
|
g_object_unref (viewable);
|
|
|
|
}
|
|
|
|
|
2003-02-04 07:54:19 +08:00
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
/***********************
|
|
|
|
* number pair entry *
|
|
|
|
***********************/
|
2007-08-08 14:32:45 +08:00
|
|
|
|
2006-09-23 02:27:21 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GObject *config;
|
2007-08-10 18:52:35 +08:00
|
|
|
const gchar *left_number_property;
|
|
|
|
const gchar *right_number_property;
|
2007-08-10 22:57:27 +08:00
|
|
|
const gchar *default_left_number_property;
|
|
|
|
const gchar *default_right_number_property;
|
|
|
|
const gchar *user_override_property;
|
2007-08-10 18:52:35 +08:00
|
|
|
} GimpPropNumberPairEntryData;
|
2006-09-23 02:27:21 +08:00
|
|
|
|
2007-05-22 23:24:49 +08:00
|
|
|
static void
|
2007-08-10 18:52:35 +08:00
|
|
|
gimp_prop_number_pair_entry_data_free (GimpPropNumberPairEntryData *data)
|
2007-05-22 23:24:49 +08:00
|
|
|
{
|
2007-08-10 18:52:35 +08:00
|
|
|
g_slice_free (GimpPropNumberPairEntryData, data);
|
2007-05-22 23:24:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-16 00:40:39 +08:00
|
|
|
static void gimp_prop_number_pair_entry_config_notify (GObject *config,
|
2007-08-10 18:52:35 +08:00
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkEntry *entry);
|
|
|
|
static void gimp_prop_number_pair_entry_number_pair_numbers_changed
|
|
|
|
(GtkWidget *widget,
|
|
|
|
GimpPropNumberPairEntryData *data);
|
2007-08-11 15:56:18 +08:00
|
|
|
static void gimp_prop_number_pair_entry_number_pair_user_override_notify
|
2007-08-10 22:57:27 +08:00
|
|
|
(GtkWidget *entry,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GimpPropNumberPairEntryData *data);
|
|
|
|
|
2007-02-08 23:35:49 +08:00
|
|
|
|
2006-09-15 01:11:24 +08:00
|
|
|
/**
|
2007-08-10 18:52:35 +08:00
|
|
|
* gimp_prop_number_pair_entry_new:
|
2007-08-10 22:57:27 +08:00
|
|
|
* @config: Object to which properties are attached.
|
|
|
|
* @left_number_property: Name of double property for left number.
|
|
|
|
* @right_number_property: Name of double property for right number.
|
|
|
|
* @default_left_number_property: Name of double property for default left number.
|
|
|
|
* @default_right_number_property: Name of double property for default right number.
|
|
|
|
* @user_override_property: Name of boolean property for user override mode.
|
|
|
|
* @connect_numbers_changed: %TRUE to connect to the widgets "numbers-changed"
|
|
|
|
* signal, %FALSE to not connect.
|
2007-08-16 00:40:39 +08:00
|
|
|
* @connect_ratio_changed: %TRUE to connect to the widgets "ratio-changed"
|
2007-08-10 22:57:27 +08:00
|
|
|
* signal, %FALSE to not connect.
|
2007-08-10 18:52:35 +08:00
|
|
|
* @separators:
|
|
|
|
* @allow_simplification:
|
|
|
|
* @min_valid_value:
|
|
|
|
* @max_valid_value: What to pass to gimp_number_pair_entry_new ().
|
2006-09-15 01:11:24 +08:00
|
|
|
*
|
2007-08-09 02:08:24 +08:00
|
|
|
* Return value: A #GimpNumberPairEntry widget.
|
2006-09-15 01:11:24 +08:00
|
|
|
*/
|
2009-08-05 03:26:32 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_number_pair_entry_new (GObject *config,
|
|
|
|
const gchar *left_number_property,
|
|
|
|
const gchar *right_number_property,
|
|
|
|
const gchar *default_left_number_property,
|
|
|
|
const gchar *default_right_number_property,
|
|
|
|
const gchar *user_override_property,
|
|
|
|
gboolean connect_numbers_changed,
|
|
|
|
gboolean connect_ratio_changed,
|
|
|
|
const gchar *separators,
|
|
|
|
gboolean allow_simplification,
|
|
|
|
gdouble min_valid_value,
|
|
|
|
gdouble max_valid_value)
|
2006-09-15 01:11:24 +08:00
|
|
|
{
|
2007-08-10 18:52:35 +08:00
|
|
|
GimpPropNumberPairEntryData *data;
|
|
|
|
GtkWidget *number_pair_entry;
|
|
|
|
gdouble left_number;
|
|
|
|
gdouble right_number;
|
2007-08-10 22:57:27 +08:00
|
|
|
gdouble default_left_number;
|
|
|
|
gdouble default_right_number;
|
|
|
|
gboolean user_override;
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup config data */
|
|
|
|
|
|
|
|
data = g_slice_new (GimpPropNumberPairEntryData);
|
|
|
|
|
|
|
|
data->config = config;
|
|
|
|
data->left_number_property = left_number_property;
|
|
|
|
data->right_number_property = right_number_property;
|
|
|
|
data->default_left_number_property = default_left_number_property;
|
|
|
|
data->default_right_number_property = default_right_number_property;
|
|
|
|
data->user_override_property = user_override_property;
|
|
|
|
|
|
|
|
|
|
|
|
/* Read current values of config properties */
|
2006-09-15 01:11:24 +08:00
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
g_object_get (config,
|
2007-08-10 22:57:27 +08:00
|
|
|
left_number_property, &left_number,
|
|
|
|
right_number_property, &right_number,
|
|
|
|
default_left_number_property, &default_left_number,
|
|
|
|
default_right_number_property, &default_right_number,
|
|
|
|
user_override_property, &user_override,
|
2007-08-09 02:08:24 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
2007-08-10 22:57:27 +08:00
|
|
|
/* Create a GimpNumberPairEntry and setup with config property values */
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
number_pair_entry = gimp_number_pair_entry_new (separators,
|
|
|
|
allow_simplification,
|
|
|
|
min_valid_value,
|
|
|
|
max_valid_value);
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
g_object_set_data_full (G_OBJECT (number_pair_entry),
|
|
|
|
"gimp-prop-number-pair-entry-data", data,
|
|
|
|
(GDestroyNotify) gimp_prop_number_pair_entry_data_free);
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 22:57:27 +08:00
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (number_pair_entry), 7);
|
|
|
|
|
|
|
|
gimp_number_pair_entry_set_user_override (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
|
|
|
|
user_override);
|
|
|
|
gimp_number_pair_entry_set_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
|
|
|
|
left_number,
|
|
|
|
right_number);
|
|
|
|
gimp_number_pair_entry_set_default_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
|
|
|
|
default_left_number,
|
|
|
|
default_right_number);
|
|
|
|
|
|
|
|
|
|
|
|
/* Connect to GimpNumberPairEntry signals */
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
if (connect_ratio_changed)
|
|
|
|
g_signal_connect (number_pair_entry, "ratio-changed",
|
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_number_pair_numbers_changed),
|
|
|
|
data);
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
if (connect_numbers_changed)
|
|
|
|
g_signal_connect (number_pair_entry, "numbers-changed",
|
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_number_pair_numbers_changed),
|
|
|
|
data);
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 22:57:27 +08:00
|
|
|
g_signal_connect (number_pair_entry, "notify::user-override",
|
2007-08-11 15:56:18 +08:00
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_number_pair_user_override_notify),
|
2007-08-10 22:57:27 +08:00
|
|
|
data);
|
|
|
|
|
|
|
|
|
|
|
|
/* Connect to connfig object signals */
|
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
connect_notify (config, left_number_property,
|
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
|
|
|
|
number_pair_entry);
|
|
|
|
connect_notify (config, right_number_property,
|
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
|
|
|
|
number_pair_entry);
|
2007-08-10 22:57:27 +08:00
|
|
|
connect_notify (config, default_left_number_property,
|
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
|
|
|
|
number_pair_entry);
|
|
|
|
connect_notify (config, default_right_number_property,
|
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
|
|
|
|
number_pair_entry);
|
|
|
|
connect_notify (config, user_override_property,
|
|
|
|
G_CALLBACK (gimp_prop_number_pair_entry_config_notify),
|
|
|
|
number_pair_entry);
|
|
|
|
|
|
|
|
|
|
|
|
/* Done */
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
return number_pair_entry;
|
2007-08-09 02:08:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-08-10 18:52:35 +08:00
|
|
|
gimp_prop_number_pair_entry_config_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkEntry *number_pair_entry)
|
2007-08-09 02:08:24 +08:00
|
|
|
{
|
2007-08-10 22:57:27 +08:00
|
|
|
GimpPropNumberPairEntryData *data =
|
|
|
|
g_object_get_data (G_OBJECT (number_pair_entry),
|
|
|
|
"gimp-prop-number-pair-entry-data");
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 18:52:35 +08:00
|
|
|
g_return_if_fail (data != NULL);
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 23:59:26 +08:00
|
|
|
if (strcmp (param_spec->name, data->left_number_property) == 0 ||
|
|
|
|
strcmp (param_spec->name, data->right_number_property) == 0)
|
2007-08-10 22:57:27 +08:00
|
|
|
{
|
|
|
|
gdouble left_number;
|
|
|
|
gdouble right_number;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
data->left_number_property, &left_number,
|
|
|
|
data->right_number_property, &right_number,
|
|
|
|
NULL);
|
2007-08-09 02:08:24 +08:00
|
|
|
|
2007-08-10 22:57:27 +08:00
|
|
|
gimp_number_pair_entry_set_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
|
|
|
|
left_number,
|
|
|
|
right_number);
|
|
|
|
}
|
2007-08-10 23:59:26 +08:00
|
|
|
else if (strcmp (param_spec->name, data->default_left_number_property) == 0 ||
|
|
|
|
strcmp (param_spec->name, data->default_right_number_property) == 0)
|
2007-08-10 22:57:27 +08:00
|
|
|
{
|
|
|
|
gdouble default_left_number;
|
|
|
|
gdouble default_right_number;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
data->default_left_number_property, &default_left_number,
|
|
|
|
data->default_right_number_property, &default_right_number,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_number_pair_entry_set_default_values (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
|
|
|
|
default_left_number,
|
|
|
|
default_right_number);
|
|
|
|
}
|
2007-08-10 23:59:26 +08:00
|
|
|
else if (strcmp (param_spec->name, data->user_override_property) == 0)
|
2007-08-10 22:57:27 +08:00
|
|
|
{
|
|
|
|
gboolean user_override;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
data->user_override_property, &user_override,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_number_pair_entry_set_user_override (GIMP_NUMBER_PAIR_ENTRY (number_pair_entry),
|
|
|
|
user_override);
|
|
|
|
}
|
2007-08-09 02:08:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-08-10 18:52:35 +08:00
|
|
|
gimp_prop_number_pair_entry_number_pair_numbers_changed (GtkWidget *widget,
|
|
|
|
GimpPropNumberPairEntryData *data)
|
2007-08-09 02:08:24 +08:00
|
|
|
{
|
2007-08-10 18:52:35 +08:00
|
|
|
gdouble left_number;
|
|
|
|
gdouble right_number;
|
2007-08-09 02:08:24 +08:00
|
|
|
|
|
|
|
gimp_number_pair_entry_get_values (GIMP_NUMBER_PAIR_ENTRY (widget),
|
2007-08-10 18:52:35 +08:00
|
|
|
&left_number,
|
|
|
|
&right_number);
|
2007-08-09 02:08:24 +08:00
|
|
|
|
|
|
|
g_object_set (data->config,
|
2007-08-10 18:52:35 +08:00
|
|
|
data->left_number_property, left_number,
|
|
|
|
data->right_number_property, right_number,
|
2006-09-24 03:40:40 +08:00
|
|
|
NULL);
|
|
|
|
}
|
2007-02-12 19:01:08 +08:00
|
|
|
|
2007-08-10 22:57:27 +08:00
|
|
|
static void
|
2007-08-11 15:56:18 +08:00
|
|
|
gimp_prop_number_pair_entry_number_pair_user_override_notify (GtkWidget *entry,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GimpPropNumberPairEntryData *data)
|
2007-08-10 22:57:27 +08:00
|
|
|
|
|
|
|
{
|
2007-08-11 15:56:18 +08:00
|
|
|
gboolean old_config_user_override;
|
|
|
|
gboolean new_config_user_override;
|
2007-08-10 22:57:27 +08:00
|
|
|
|
2007-08-11 15:56:18 +08:00
|
|
|
g_object_get (data->config,
|
|
|
|
data->user_override_property, &old_config_user_override,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
new_config_user_override =
|
2007-08-10 22:57:27 +08:00
|
|
|
gimp_number_pair_entry_get_user_override (GIMP_NUMBER_PAIR_ENTRY (entry));
|
|
|
|
|
2007-08-11 15:56:18 +08:00
|
|
|
/* Only set when property changed, to avoid deadlocks */
|
|
|
|
if (new_config_user_override != old_config_user_override)
|
|
|
|
g_object_set (data->config,
|
|
|
|
data->user_override_property, new_config_user_override,
|
|
|
|
NULL);
|
2007-08-10 22:57:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 05:21:54 +08:00
|
|
|
/************************/
|
|
|
|
/* language combo-box */
|
|
|
|
/************************/
|
|
|
|
|
|
|
|
static void gimp_prop_language_combo_box_callback (GtkWidget *combo,
|
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_language_combo_box_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *combo);
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_language_combo_box_new (GObject *config,
|
|
|
|
const gchar *property_name)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkWidget *combo;
|
|
|
|
gchar *value;
|
|
|
|
|
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_STRING, G_STRFUNC);
|
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
combo = gimp_language_combo_box_new ();
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
property_name, &value,
|
|
|
|
NULL);
|
|
|
|
|
2009-12-31 21:13:11 +08:00
|
|
|
gimp_language_combo_box_set_code (GIMP_LANGUAGE_COMBO_BOX (combo), value);
|
2009-12-31 05:21:54 +08:00
|
|
|
g_free (value);
|
|
|
|
|
|
|
|
set_param_spec (G_OBJECT (combo), combo, param_spec);
|
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (gimp_prop_language_combo_box_callback),
|
|
|
|
config);
|
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
|
|
|
G_CALLBACK (gimp_prop_language_combo_box_notify),
|
|
|
|
combo);
|
|
|
|
|
|
|
|
return combo;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_language_combo_box_callback (GtkWidget *combo,
|
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
gchar *code;
|
|
|
|
|
|
|
|
param_spec = get_param_spec (G_OBJECT (combo));
|
|
|
|
if (! param_spec)
|
|
|
|
return;
|
|
|
|
|
2009-12-31 21:13:11 +08:00
|
|
|
code = gimp_language_combo_box_get_code (GIMP_LANGUAGE_COMBO_BOX (combo));
|
2009-12-31 05:21:54 +08:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (config,
|
|
|
|
gimp_prop_language_combo_box_notify,
|
|
|
|
combo);
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
param_spec->name, code,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (config,
|
|
|
|
gimp_prop_language_combo_box_notify,
|
|
|
|
combo);
|
|
|
|
|
|
|
|
g_free (code);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_language_combo_box_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *combo)
|
|
|
|
{
|
|
|
|
gchar *value;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &value,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (combo,
|
|
|
|
gimp_prop_language_combo_box_callback,
|
|
|
|
config);
|
|
|
|
|
2009-12-31 21:13:11 +08:00
|
|
|
gimp_language_combo_box_set_code (GIMP_LANGUAGE_COMBO_BOX (combo), value);
|
2009-12-31 05:21:54 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (combo,
|
|
|
|
gimp_prop_language_combo_box_callback,
|
|
|
|
config);
|
|
|
|
|
|
|
|
g_free (value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-05 03:26:32 +08:00
|
|
|
/********************/
|
|
|
|
/* language entry */
|
|
|
|
/********************/
|
|
|
|
|
|
|
|
static void gimp_prop_language_entry_callback (GtkWidget *entry,
|
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_language_entry_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *entry);
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_language_entry_new (GObject *config,
|
|
|
|
const gchar *property_name)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkWidget *entry;
|
|
|
|
gchar *value;
|
|
|
|
|
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_STRING, G_STRFUNC);
|
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
entry = gimp_language_entry_new ();
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
property_name, &value,
|
|
|
|
NULL);
|
|
|
|
|
2009-12-31 21:13:11 +08:00
|
|
|
gimp_language_entry_set_code (GIMP_LANGUAGE_ENTRY (entry), value);
|
2009-08-05 03:26:32 +08:00
|
|
|
g_free (value);
|
|
|
|
|
|
|
|
set_param_spec (G_OBJECT (entry), entry, param_spec);
|
|
|
|
|
|
|
|
g_signal_connect (entry, "changed",
|
|
|
|
G_CALLBACK (gimp_prop_language_entry_callback),
|
|
|
|
config);
|
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
|
|
|
G_CALLBACK (gimp_prop_language_entry_notify),
|
|
|
|
entry);
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_language_entry_callback (GtkWidget *entry,
|
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
2009-08-05 04:31:52 +08:00
|
|
|
const gchar *code;
|
2009-08-05 03:26:32 +08:00
|
|
|
|
|
|
|
param_spec = get_param_spec (G_OBJECT (entry));
|
|
|
|
if (! param_spec)
|
|
|
|
return;
|
|
|
|
|
2009-12-31 21:13:11 +08:00
|
|
|
code = gimp_language_entry_get_code (GIMP_LANGUAGE_ENTRY (entry));
|
2009-08-05 03:26:32 +08:00
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (config,
|
|
|
|
gimp_prop_language_entry_notify,
|
|
|
|
entry);
|
|
|
|
|
|
|
|
g_object_set (config,
|
2009-08-05 04:31:52 +08:00
|
|
|
param_spec->name, code,
|
2009-08-05 03:26:32 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (config,
|
|
|
|
gimp_prop_language_entry_notify,
|
|
|
|
entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_language_entry_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *entry)
|
|
|
|
{
|
|
|
|
gchar *value;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &value,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (entry,
|
|
|
|
gimp_prop_language_entry_callback,
|
|
|
|
config);
|
|
|
|
|
2009-12-31 21:13:11 +08:00
|
|
|
gimp_language_entry_set_code (GIMP_LANGUAGE_ENTRY (entry), value);
|
2009-08-05 03:26:32 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (entry,
|
|
|
|
gimp_prop_language_entry_callback,
|
|
|
|
config);
|
|
|
|
|
|
|
|
g_free (value);
|
|
|
|
}
|
|
|
|
|
2013-03-11 02:48:32 +08:00
|
|
|
|
2016-05-09 02:38:46 +08:00
|
|
|
/***********************/
|
|
|
|
/* profile combo box */
|
|
|
|
/***********************/
|
|
|
|
|
|
|
|
static void gimp_prop_profile_combo_callback (GimpColorProfileComboBox *combo,
|
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_profile_combo_notify (GObject *config,
|
|
|
|
const GParamSpec *param_spec,
|
|
|
|
GimpColorProfileComboBox *combo);
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_profile_combo_box_new (GObject *config,
|
|
|
|
const gchar *property_name,
|
|
|
|
GtkListStore *profile_store,
|
|
|
|
const gchar *dialog_title)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *combo;
|
|
|
|
GFile *file = NULL;
|
|
|
|
|
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_STRING, G_STRFUNC);
|
|
|
|
if (! param_spec)
|
|
|
|
{
|
|
|
|
param_spec = check_param_spec_w (config, property_name,
|
|
|
|
G_TYPE_PARAM_OBJECT, G_STRFUNC);
|
|
|
|
if (! param_spec)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog = gimp_color_profile_chooser_dialog_new (dialog_title, NULL,
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN);
|
|
|
|
|
|
|
|
if (G_IS_PARAM_SPEC_STRING (param_spec))
|
|
|
|
{
|
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
g_object_get (config, property_name, &path, NULL);
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
file = g_file_new_for_path (path);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_get (config, property_name, &file, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (profile_store)
|
|
|
|
combo = gimp_color_profile_combo_box_new_with_model (dialog,
|
|
|
|
GTK_TREE_MODEL (profile_store));
|
|
|
|
else
|
|
|
|
combo = gimp_color_profile_combo_box_new (dialog, /* FIXME */ NULL);
|
|
|
|
|
|
|
|
gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
|
|
|
file, NULL);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
g_object_unref (file);
|
|
|
|
|
|
|
|
set_param_spec (G_OBJECT (combo), combo, param_spec);
|
|
|
|
|
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (gimp_prop_profile_combo_callback),
|
|
|
|
config);
|
|
|
|
|
|
|
|
connect_notify (config, property_name,
|
|
|
|
G_CALLBACK (gimp_prop_profile_combo_notify),
|
|
|
|
combo);
|
|
|
|
|
|
|
|
return combo;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_profile_combo_callback (GimpColorProfileComboBox *combo,
|
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
GFile *file;
|
|
|
|
|
|
|
|
param_spec = get_param_spec (G_OBJECT (combo));
|
|
|
|
if (! param_spec)
|
|
|
|
return;
|
|
|
|
|
|
|
|
file = gimp_color_profile_combo_box_get_active_file (combo);
|
|
|
|
|
|
|
|
if (! file)
|
|
|
|
g_signal_handlers_block_by_func (config,
|
|
|
|
gimp_prop_profile_combo_notify,
|
|
|
|
combo);
|
|
|
|
|
|
|
|
if (G_IS_PARAM_SPEC_STRING (param_spec))
|
|
|
|
{
|
|
|
|
gchar *path = NULL;
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
path = g_file_get_path (file);
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
param_spec->name, path,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_set (config,
|
|
|
|
param_spec->name, file,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! file)
|
|
|
|
g_signal_handlers_unblock_by_func (config,
|
|
|
|
gimp_prop_profile_combo_notify,
|
|
|
|
combo);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
g_object_unref (file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_profile_combo_notify (GObject *config,
|
|
|
|
const GParamSpec *param_spec,
|
|
|
|
GimpColorProfileComboBox *combo)
|
|
|
|
{
|
|
|
|
GFile *file = NULL;
|
|
|
|
|
|
|
|
if (G_IS_PARAM_SPEC_STRING (param_spec))
|
|
|
|
{
|
|
|
|
gchar *path;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &path,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
file = g_file_new_for_path (path);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_object_get (config,
|
|
|
|
param_spec->name, &file,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (combo,
|
|
|
|
gimp_prop_profile_combo_callback,
|
|
|
|
config);
|
|
|
|
|
|
|
|
gimp_color_profile_combo_box_set_active_file (combo, file, NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (combo,
|
|
|
|
gimp_prop_profile_combo_callback,
|
|
|
|
config);
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
g_object_unref (file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-22 22:20:03 +08:00
|
|
|
/*****************/
|
|
|
|
/* icon picker */
|
|
|
|
/*****************/
|
|
|
|
|
|
|
|
static void gimp_prop_icon_picker_callback (GtkWidget *picker,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GObject *config);
|
|
|
|
static void gimp_prop_icon_picker_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *picker);
|
|
|
|
|
|
|
|
GtkWidget *
|
2012-12-12 12:50:45 +08:00
|
|
|
gimp_prop_icon_picker_new (GimpViewable *viewable,
|
|
|
|
Gimp *gimp)
|
2011-03-22 22:20:03 +08:00
|
|
|
{
|
2014-05-09 08:24:42 +08:00
|
|
|
GObject *object = G_OBJECT (viewable);
|
|
|
|
GtkWidget *picker = NULL;
|
|
|
|
GdkPixbuf *pixbuf_value = NULL;
|
|
|
|
gchar *icon_name_value = NULL;
|
2011-03-22 22:20:03 +08:00
|
|
|
|
2012-12-12 12:50:45 +08:00
|
|
|
picker = gimp_icon_picker_new (gimp);
|
2011-03-22 22:20:03 +08:00
|
|
|
|
2012-12-12 12:50:45 +08:00
|
|
|
g_object_get (object,
|
2014-05-09 08:24:42 +08:00
|
|
|
"icon-name", &icon_name_value,
|
2012-12-12 12:50:45 +08:00
|
|
|
"icon-pixbuf", &pixbuf_value,
|
2011-03-22 22:20:03 +08:00
|
|
|
NULL);
|
|
|
|
|
2014-05-09 08:24:42 +08:00
|
|
|
gimp_icon_picker_set_icon_name (GIMP_ICON_PICKER (picker), icon_name_value);
|
2012-12-12 12:50:45 +08:00
|
|
|
gimp_icon_picker_set_icon_pixbuf (GIMP_ICON_PICKER (picker), pixbuf_value);
|
2011-03-22 22:20:03 +08:00
|
|
|
|
2012-12-12 12:50:45 +08:00
|
|
|
g_signal_connect (picker, "notify::icon-pixbuf",
|
|
|
|
G_CALLBACK (gimp_prop_icon_picker_callback),
|
|
|
|
object);
|
2011-03-22 22:20:03 +08:00
|
|
|
|
2014-05-09 08:24:42 +08:00
|
|
|
g_signal_connect (picker, "notify::icon-name",
|
2011-03-22 22:20:03 +08:00
|
|
|
G_CALLBACK (gimp_prop_icon_picker_callback),
|
2012-12-12 12:50:45 +08:00
|
|
|
object);
|
2011-03-22 22:20:03 +08:00
|
|
|
|
2014-05-09 08:24:42 +08:00
|
|
|
connect_notify (object, "icon-name",
|
2011-03-22 22:20:03 +08:00
|
|
|
G_CALLBACK (gimp_prop_icon_picker_notify),
|
|
|
|
picker);
|
|
|
|
|
2012-12-12 12:50:45 +08:00
|
|
|
connect_notify (object, "icon-pixbuf",
|
|
|
|
G_CALLBACK (gimp_prop_icon_picker_notify),
|
|
|
|
picker);
|
|
|
|
|
2014-05-09 08:24:42 +08:00
|
|
|
if (icon_name_value)
|
|
|
|
g_free (icon_name_value);
|
2012-12-12 12:50:45 +08:00
|
|
|
if (pixbuf_value)
|
|
|
|
g_object_unref (pixbuf_value);
|
|
|
|
|
2011-03-22 22:20:03 +08:00
|
|
|
return picker;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_icon_picker_callback (GtkWidget *picker,
|
2012-12-12 12:50:45 +08:00
|
|
|
GParamSpec *param_spec,
|
2011-03-22 22:20:03 +08:00
|
|
|
GObject *config)
|
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (config,
|
|
|
|
gimp_prop_icon_picker_notify,
|
|
|
|
picker);
|
|
|
|
|
2014-05-09 08:24:42 +08:00
|
|
|
if (! strcmp (param_spec->name, "icon-name"))
|
2012-12-12 12:50:45 +08:00
|
|
|
{
|
2014-05-09 08:24:42 +08:00
|
|
|
const gchar *value = gimp_icon_picker_get_icon_name (GIMP_ICON_PICKER (picker));
|
2012-12-12 12:50:45 +08:00
|
|
|
|
|
|
|
g_object_set (config,
|
2014-05-09 08:24:42 +08:00
|
|
|
"icon-name", value,
|
2012-12-12 12:50:45 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
}
|
2013-03-11 02:48:32 +08:00
|
|
|
else if (! strcmp (param_spec->name, "icon-pixbuf"))
|
2012-12-12 12:50:45 +08:00
|
|
|
{
|
|
|
|
GdkPixbuf *value = gimp_icon_picker_get_icon_pixbuf (GIMP_ICON_PICKER (picker));
|
|
|
|
|
|
|
|
g_object_set (config,
|
|
|
|
"icon-pixbuf", value,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2011-03-22 22:20:03 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (config,
|
|
|
|
gimp_prop_icon_picker_notify,
|
|
|
|
picker);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_prop_icon_picker_notify (GObject *config,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
GtkWidget *picker)
|
|
|
|
{
|
|
|
|
g_signal_handlers_block_by_func (picker,
|
|
|
|
gimp_prop_icon_picker_callback,
|
|
|
|
config);
|
|
|
|
|
2014-05-09 08:24:42 +08:00
|
|
|
if (!strcmp (param_spec->name, "icon-name"))
|
2012-12-12 12:50:45 +08:00
|
|
|
{
|
|
|
|
gchar *value = NULL;
|
2011-03-22 22:20:03 +08:00
|
|
|
|
2012-12-12 12:50:45 +08:00
|
|
|
g_object_get (config,
|
2014-05-09 08:24:42 +08:00
|
|
|
"icon-name", &value,
|
2012-12-12 12:50:45 +08:00
|
|
|
NULL);
|
|
|
|
|
2014-05-09 08:24:42 +08:00
|
|
|
gimp_icon_picker_set_icon_name (GIMP_ICON_PICKER (picker), value);
|
2012-12-12 12:50:45 +08:00
|
|
|
|
|
|
|
if (value)
|
|
|
|
g_free (value);
|
|
|
|
}
|
|
|
|
else if (!strcmp (param_spec->name, "icon-pixbuf"))
|
|
|
|
{
|
|
|
|
GdkPixbuf *value = NULL;
|
|
|
|
|
|
|
|
g_object_get (config,
|
|
|
|
"icon-pixbuf", &value,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_icon_picker_set_icon_pixbuf (GIMP_ICON_PICKER (picker), value);
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
g_object_unref (value);
|
|
|
|
}
|
2011-03-22 22:20:03 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (picker,
|
|
|
|
gimp_prop_icon_picker_callback,
|
|
|
|
config);
|
|
|
|
}
|
|
|
|
|
2013-03-11 02:48:32 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
/******************************/
|
|
|
|
/* public utility functions */
|
|
|
|
/******************************/
|
2008-02-05 21:20:11 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
gboolean
|
|
|
|
_gimp_prop_widgets_get_numeric_values (GObject *object,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
gdouble *value,
|
|
|
|
gdouble *lower,
|
|
|
|
gdouble *upper,
|
|
|
|
const gchar *strloc)
|
2012-05-19 08:30:32 +08:00
|
|
|
{
|
2013-05-30 22:33:30 +08:00
|
|
|
if (G_IS_PARAM_SPEC_INT (param_spec))
|
2012-05-19 08:30:32 +08:00
|
|
|
{
|
2013-05-30 22:33:30 +08:00
|
|
|
GParamSpecInt *int_spec = G_PARAM_SPEC_INT (param_spec);
|
|
|
|
gint int_value;
|
2012-05-19 08:30:32 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
g_object_get (object, param_spec->name, &int_value, NULL);
|
2012-05-19 08:30:32 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
*value = int_value;
|
|
|
|
*lower = int_spec->minimum;
|
|
|
|
*upper = int_spec->maximum;
|
2012-05-19 08:30:32 +08:00
|
|
|
}
|
2013-05-30 22:33:30 +08:00
|
|
|
else if (G_IS_PARAM_SPEC_UINT (param_spec))
|
2012-05-19 08:30:32 +08:00
|
|
|
{
|
2013-05-30 22:33:30 +08:00
|
|
|
GParamSpecUInt *uint_spec = G_PARAM_SPEC_UINT (param_spec);
|
|
|
|
guint uint_value;
|
2012-05-19 08:30:32 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
g_object_get (object, param_spec->name, &uint_value, NULL);
|
2012-05-19 08:30:32 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
*value = uint_value;
|
|
|
|
*lower = uint_spec->minimum;
|
|
|
|
*upper = uint_spec->maximum;
|
2012-05-19 08:30:32 +08:00
|
|
|
}
|
2013-05-30 22:33:30 +08:00
|
|
|
else if (G_IS_PARAM_SPEC_DOUBLE (param_spec))
|
|
|
|
{
|
|
|
|
GParamSpecDouble *double_spec = G_PARAM_SPEC_DOUBLE (param_spec);
|
2008-02-05 21:20:11 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
g_object_get (object, param_spec->name, value, NULL);
|
2008-02-05 21:20:11 +08:00
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
*lower = double_spec->minimum;
|
|
|
|
*upper = double_spec->maximum;
|
|
|
|
}
|
|
|
|
else
|
2008-02-05 21:20:11 +08:00
|
|
|
{
|
2013-05-30 22:33:30 +08:00
|
|
|
g_warning ("%s: property '%s' of %s is not numeric",
|
|
|
|
strloc,
|
|
|
|
param_spec->name,
|
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (object)));
|
|
|
|
return FALSE;
|
2008-02-05 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
2013-05-30 22:33:30 +08:00
|
|
|
return TRUE;
|
2008-02-05 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-02-12 19:01:08 +08:00
|
|
|
/*******************************/
|
|
|
|
/* private utility functions */
|
|
|
|
/*******************************/
|
|
|
|
|
2007-08-08 17:56:51 +08:00
|
|
|
static GQuark gimp_prop_widgets_param_spec_quark (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
#define PARAM_SPEC_QUARK (gimp_prop_widgets_param_spec_quark ())
|
|
|
|
|
|
|
|
static GQuark
|
|
|
|
gimp_prop_widgets_param_spec_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark param_spec_quark = 0;
|
|
|
|
|
|
|
|
if (! param_spec_quark)
|
|
|
|
param_spec_quark = g_quark_from_static_string ("gimp-config-param-spec");
|
|
|
|
|
|
|
|
return param_spec_quark;
|
|
|
|
}
|
2007-02-12 19:01:08 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
set_param_spec (GObject *object,
|
|
|
|
GtkWidget *widget,
|
|
|
|
GParamSpec *param_spec)
|
|
|
|
{
|
|
|
|
if (object)
|
|
|
|
{
|
2007-08-08 17:56:51 +08:00
|
|
|
g_object_set_qdata (object, PARAM_SPEC_QUARK, param_spec);
|
2007-02-12 19:01:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widget)
|
|
|
|
{
|
|
|
|
const gchar *blurb = g_param_spec_get_blurb (param_spec);
|
|
|
|
|
|
|
|
if (blurb)
|
2014-05-15 05:34:01 +08:00
|
|
|
gimp_help_set_help_data (widget, blurb, NULL);
|
2007-02-12 19:01:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GParamSpec *
|
|
|
|
get_param_spec (GObject *object)
|
|
|
|
{
|
2007-08-08 17:56:51 +08:00
|
|
|
return g_object_get_qdata (object, PARAM_SPEC_QUARK);
|
2007-02-12 19:01:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GParamSpec *
|
|
|
|
find_param_spec (GObject *object,
|
|
|
|
const gchar *property_name,
|
|
|
|
const gchar *strloc)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
|
|
|
|
param_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
|
|
|
|
property_name);
|
|
|
|
|
|
|
|
if (! param_spec)
|
|
|
|
g_warning ("%s: %s has no property named '%s'",
|
|
|
|
strloc,
|
|
|
|
g_type_name (G_TYPE_FROM_INSTANCE (object)),
|
|
|
|
property_name);
|
|
|
|
|
|
|
|
return param_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GParamSpec *
|
|
|
|
check_param_spec (GObject *object,
|
|
|
|
const gchar *property_name,
|
|
|
|
GType type,
|
|
|
|
const gchar *strloc)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
|
|
|
|
param_spec = find_param_spec (object, property_name, strloc);
|
|
|
|
|
|
|
|
if (param_spec && ! g_type_is_a (G_TYPE_FROM_INSTANCE (param_spec), type))
|
|
|
|
{
|
|
|
|
g_warning ("%s: property '%s' of %s is not a %s",
|
|
|
|
strloc,
|
|
|
|
param_spec->name,
|
|
|
|
g_type_name (param_spec->owner_type),
|
|
|
|
g_type_name (type));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return param_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GParamSpec *
|
|
|
|
check_param_spec_w (GObject *object,
|
|
|
|
const gchar *property_name,
|
|
|
|
GType type,
|
|
|
|
const gchar *strloc)
|
|
|
|
{
|
|
|
|
GParamSpec *param_spec;
|
|
|
|
|
|
|
|
param_spec = check_param_spec (object, property_name, type, strloc);
|
|
|
|
|
|
|
|
if (param_spec &&
|
|
|
|
(param_spec->flags & G_PARAM_WRITABLE) == 0)
|
|
|
|
{
|
|
|
|
g_warning ("%s: property '%s' of %s is writable",
|
|
|
|
strloc,
|
|
|
|
param_spec->name,
|
|
|
|
g_type_name (param_spec->owner_type));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return param_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
connect_notify (GObject *config,
|
|
|
|
const gchar *property_name,
|
|
|
|
GCallback callback,
|
|
|
|
gpointer callback_data)
|
|
|
|
{
|
|
|
|
gchar *notify_name;
|
|
|
|
|
|
|
|
notify_name = g_strconcat ("notify::", property_name, NULL);
|
|
|
|
|
|
|
|
g_signal_connect_object (config, notify_name, callback, callback_data, 0);
|
|
|
|
|
|
|
|
g_free (notify_name);
|
|
|
|
}
|