2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2004-10-12 20:06:50 +08:00
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2004-10-12 20:06:50 +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
|
2004-10-12 20:06:50 +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/>.
|
2004-10-12 20:06:50 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-03-30 01:19:01 +08:00
|
|
|
#include <gegl.h>
|
2004-10-12 20:06:50 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
#include "config/gimpconfig-utils.h"
|
|
|
|
|
2004-10-12 20:06:50 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdatafactory.h"
|
|
|
|
|
|
|
|
#include "gimpcontainerentry.h"
|
|
|
|
#include "gimpdialogfactory.h"
|
|
|
|
#include "gimppropwidgets.h"
|
|
|
|
#include "gimpview.h"
|
|
|
|
#include "gimpviewablebutton.h"
|
|
|
|
#include "gimpviewablebox.h"
|
|
|
|
#include "gimpviewrenderergradient.h"
|
2014-05-02 09:01:23 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2012-01-31 06:52:59 +08:00
|
|
|
#include "gimpwindowstrategy.h"
|
2004-10-12 20:06:50 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
static GtkWidget * gimp_viewable_box_new (GimpContainer *container,
|
2005-09-11 04:35:13 +08:00
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2005-09-11 04:35:13 +08:00
|
|
|
gint spacing,
|
2005-10-31 10:12:40 +08:00
|
|
|
GimpViewType view_type,
|
2015-01-10 06:47:13 +08:00
|
|
|
GimpViewSize button_view_size,
|
2005-09-11 04:35:13 +08:00
|
|
|
GimpViewSize view_size,
|
|
|
|
const gchar *dialog_identifier,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *dialog_icon_name,
|
2011-04-08 05:48:08 +08:00
|
|
|
const gchar *dialog_tooltip,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip);
|
2006-01-14 08:09:22 +08:00
|
|
|
static GtkWidget * view_props_connect (GtkWidget *box,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *view_type_prop,
|
|
|
|
const gchar *view_size_prop);
|
2011-04-08 05:48:08 +08:00
|
|
|
static void gimp_viewable_box_edit_clicked (GtkWidget *widget,
|
|
|
|
GimpViewableButton *button);
|
2005-09-11 04:35:13 +08:00
|
|
|
static void gimp_gradient_box_reverse_notify (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpView *view);
|
2004-10-12 20:06:50 +08:00
|
|
|
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
/* brush boxes */
|
2004-10-12 20:06:50 +08:00
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
static GtkWidget *
|
|
|
|
brush_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
GimpViewType view_type,
|
2011-04-08 05:48:08 +08:00
|
|
|
GimpViewSize view_size,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2004-10-12 20:06:50 +08:00
|
|
|
{
|
|
|
|
if (! container)
|
2008-12-20 05:58:17 +08:00
|
|
|
container = gimp_data_factory_get_container (context->gimp->brush_factory);
|
2004-10-12 20:06:50 +08:00
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return gimp_viewable_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, GIMP_VIEW_SIZE_SMALL, view_size,
|
2005-09-11 04:35:13 +08:00
|
|
|
"gimp-brush-grid|gimp-brush-list",
|
|
|
|
GIMP_STOCK_BRUSH,
|
2011-04-08 05:48:08 +08:00
|
|
|
_("Open the brush selection dialog"),
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip);
|
2004-10-12 20:06:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2006-01-14 08:09:22 +08:00
|
|
|
gimp_brush_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing)
|
2004-10-12 20:06:50 +08:00
|
|
|
{
|
2005-09-11 04:35:13 +08:00
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
2004-10-12 20:06:50 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return brush_box_new (container, context, label, spacing,
|
2011-04-08 05:48:08 +08:00
|
|
|
GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_SMALL,
|
2016-09-17 23:10:20 +08:00
|
|
|
NULL, NULL);
|
2006-01-14 08:09:22 +08:00
|
|
|
}
|
2010-11-02 21:05:47 +08:00
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_brush_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
const gchar *view_type_prop,
|
2011-04-08 05:48:08 +08:00
|
|
|
const gchar *view_size_prop,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2006-01-14 08:09:22 +08:00
|
|
|
{
|
|
|
|
GimpViewType view_type;
|
|
|
|
GimpViewSize view_size;
|
|
|
|
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
g_object_get (context,
|
|
|
|
view_type_prop, &view_type,
|
|
|
|
view_size_prop, &view_size,
|
|
|
|
NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return view_props_connect (brush_box_new (container, context, label, spacing,
|
2011-04-08 05:48:08 +08:00
|
|
|
view_type, view_size,
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip),
|
2006-01-14 08:09:22 +08:00
|
|
|
context,
|
|
|
|
view_type_prop, view_size_prop);
|
|
|
|
}
|
|
|
|
|
2015-12-29 03:04:29 +08:00
|
|
|
|
2010-10-28 02:48:17 +08:00
|
|
|
/* dynamics boxes */
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
dynamics_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2010-10-28 02:48:17 +08:00
|
|
|
gint spacing,
|
2011-04-08 05:48:08 +08:00
|
|
|
GimpViewSize view_size,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2010-10-28 02:48:17 +08:00
|
|
|
{
|
|
|
|
if (! container)
|
|
|
|
container = gimp_data_factory_get_container (context->gimp->dynamics_factory);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return gimp_viewable_box_new (container, context, label, spacing,
|
2010-10-28 02:48:17 +08:00
|
|
|
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_SMALL, view_size,
|
|
|
|
"gimp-dynamics-list",
|
|
|
|
GIMP_STOCK_DYNAMICS,
|
2011-04-08 05:48:08 +08:00
|
|
|
_("Open the dynamics selection dialog"),
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip);
|
2010-10-28 02:48:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_dynamics_box_new (GimpContainer *container,
|
2010-11-02 21:05:47 +08:00
|
|
|
GimpContext *context,
|
|
|
|
const gchar *label,
|
|
|
|
gint spacing)
|
2010-10-28 02:48:17 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return dynamics_box_new (container, context, label, spacing,
|
2011-04-08 05:48:08 +08:00
|
|
|
GIMP_VIEW_SIZE_SMALL,
|
2016-09-17 23:10:20 +08:00
|
|
|
NULL, NULL);
|
2010-10-28 02:48:17 +08:00
|
|
|
}
|
2010-11-02 21:05:47 +08:00
|
|
|
|
2010-10-28 02:48:17 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_dynamics_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2010-10-28 02:48:17 +08:00
|
|
|
gint spacing,
|
|
|
|
const gchar *view_type_prop,
|
2011-04-08 05:48:08 +08:00
|
|
|
const gchar *view_size_prop,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2010-10-28 02:48:17 +08:00
|
|
|
{
|
|
|
|
GimpViewType view_type;
|
|
|
|
GimpViewSize view_size;
|
|
|
|
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
g_object_get (context,
|
|
|
|
view_type_prop, &view_type,
|
|
|
|
view_size_prop, &view_size,
|
|
|
|
NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return view_props_connect (dynamics_box_new (container, context, label,
|
2011-04-08 05:48:08 +08:00
|
|
|
spacing, view_size,
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip),
|
2010-10-28 02:48:17 +08:00
|
|
|
context,
|
|
|
|
view_type_prop, view_size_prop);
|
|
|
|
}
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
|
2015-12-29 03:04:29 +08:00
|
|
|
/* brush boxes */
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
mybrush_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *label,
|
|
|
|
gint spacing,
|
|
|
|
GimpViewType view_type,
|
|
|
|
GimpViewSize view_size)
|
|
|
|
{
|
|
|
|
if (! container)
|
|
|
|
container = gimp_data_factory_get_container (context->gimp->mybrush_factory);
|
|
|
|
|
|
|
|
return gimp_viewable_box_new (container, context, label, spacing,
|
|
|
|
view_type, GIMP_VIEW_SIZE_LARGE, view_size,
|
|
|
|
"gimp-mypaint-brush-grid|gimp-mypaint-brush-list",
|
|
|
|
GIMP_STOCK_BRUSH,
|
|
|
|
_("Open the MyPaint brush selection dialog"),
|
2016-09-17 23:10:20 +08:00
|
|
|
NULL, NULL);
|
2015-12-29 03:04:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_mybrush_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *label,
|
|
|
|
gint spacing)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
return mybrush_box_new (container, context, label, spacing,
|
|
|
|
GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_LARGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_mybrush_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *label,
|
|
|
|
gint spacing,
|
|
|
|
const gchar *view_type_prop,
|
|
|
|
const gchar *view_size_prop)
|
|
|
|
{
|
|
|
|
GimpViewType view_type = GIMP_VIEW_TYPE_GRID;
|
|
|
|
GimpViewSize view_size = GIMP_VIEW_SIZE_LARGE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
if (view_type_prop && view_size_prop)
|
|
|
|
g_object_get (context,
|
|
|
|
view_type_prop, &view_type,
|
|
|
|
view_size_prop, &view_size,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return view_props_connect (mybrush_box_new (container, context, label, spacing,
|
|
|
|
view_type, view_size),
|
|
|
|
context,
|
|
|
|
view_type_prop, view_size_prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
/* pattern boxes */
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
pattern_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
GimpViewType view_type,
|
|
|
|
GimpViewSize view_size)
|
|
|
|
{
|
2004-10-12 20:06:50 +08:00
|
|
|
if (! container)
|
2008-12-20 05:58:17 +08:00
|
|
|
container = gimp_data_factory_get_container (context->gimp->pattern_factory);
|
2004-10-12 20:06:50 +08:00
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return gimp_viewable_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, GIMP_VIEW_SIZE_SMALL, view_size,
|
2005-09-11 04:35:13 +08:00
|
|
|
"gimp-pattern-grid|gimp-pattern-list",
|
|
|
|
GIMP_STOCK_PATTERN,
|
2011-04-08 05:48:08 +08:00
|
|
|
_("Open the pattern selection dialog"),
|
2016-09-17 23:10:20 +08:00
|
|
|
NULL, NULL);
|
2004-10-12 20:06:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2006-01-14 08:09:22 +08:00
|
|
|
gimp_pattern_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing)
|
2004-10-12 20:06:50 +08:00
|
|
|
{
|
2006-01-14 08:09:22 +08:00
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return pattern_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
GIMP_VIEW_TYPE_GRID, GIMP_VIEW_SIZE_SMALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_pattern_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
const gchar *view_type_prop,
|
|
|
|
const gchar *view_size_prop)
|
|
|
|
{
|
|
|
|
GimpViewType view_type;
|
|
|
|
GimpViewSize view_size;
|
2004-10-12 20:06:50 +08:00
|
|
|
|
2005-09-11 04:35:13 +08:00
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
2004-10-12 20:06:50 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
g_object_get (context,
|
|
|
|
view_type_prop, &view_type,
|
|
|
|
view_size_prop, &view_size,
|
|
|
|
NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return view_props_connect (pattern_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, view_size),
|
|
|
|
context,
|
|
|
|
view_type_prop, view_size_prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* gradient boxes */
|
|
|
|
|
2006-10-30 18:13:06 +08:00
|
|
|
static GtkWidget *
|
2006-01-14 08:09:22 +08:00
|
|
|
gradient_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
GimpViewType view_type,
|
|
|
|
GimpViewSize view_size,
|
2011-04-08 05:48:08 +08:00
|
|
|
const gchar *reverse_prop,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2006-01-14 08:09:22 +08:00
|
|
|
{
|
2007-10-17 22:36:12 +08:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *button;
|
2010-11-02 21:05:47 +08:00
|
|
|
GList *children;
|
2006-01-14 08:09:22 +08:00
|
|
|
|
2004-10-12 20:06:50 +08:00
|
|
|
if (! container)
|
2008-12-20 05:58:17 +08:00
|
|
|
container = gimp_data_factory_get_container (context->gimp->gradient_factory);
|
2004-10-12 20:06:50 +08:00
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
hbox = gimp_viewable_box_new (container, context, label, spacing,
|
2013-06-04 16:19:54 +08:00
|
|
|
view_type, GIMP_VIEW_SIZE_SMALL, view_size,
|
2010-11-02 21:05:47 +08:00
|
|
|
"gimp-gradient-list|gimp-gradient-grid",
|
|
|
|
GIMP_STOCK_GRADIENT,
|
2011-04-08 05:48:08 +08:00
|
|
|
_("Open the gradient selection dialog"),
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip);
|
2006-01-14 08:09:22 +08:00
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (hbox));
|
|
|
|
button = children->data;
|
|
|
|
g_list_free (children);
|
2006-01-14 08:09:22 +08:00
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
GIMP_VIEWABLE_BUTTON (button)->button_view_size = GIMP_VIEW_SIZE_SMALL;
|
2004-10-12 20:06:50 +08:00
|
|
|
|
|
|
|
if (reverse_prop)
|
|
|
|
{
|
|
|
|
GtkWidget *toggle;
|
2006-01-17 18:08:50 +08:00
|
|
|
GtkWidget *view;
|
2007-10-17 22:36:12 +08:00
|
|
|
GtkWidget *image;
|
2004-10-12 20:06:50 +08:00
|
|
|
gchar *signal_name;
|
|
|
|
|
|
|
|
toggle = gimp_prop_check_button_new (G_OBJECT (context), reverse_prop,
|
2007-10-17 22:36:12 +08:00
|
|
|
NULL);
|
2011-04-08 05:48:08 +08:00
|
|
|
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle), FALSE);
|
2013-06-04 16:19:54 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
|
|
|
gtk_box_reorder_child (GTK_BOX (hbox), toggle, 1);
|
2004-10-12 20:06:50 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
2007-10-17 22:36:12 +08:00
|
|
|
gimp_help_set_help_data (toggle, _("Reverse"), NULL);
|
|
|
|
|
2014-05-07 21:30:38 +08:00
|
|
|
image = gtk_image_new_from_icon_name (GIMP_STOCK_FLIP_HORIZONTAL,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
2016-02-11 22:54:36 +08:00
|
|
|
/* gimp_prop_check_button_new() adds the property nick as label of
|
|
|
|
* the button by default. */
|
|
|
|
gtk_container_remove (GTK_CONTAINER (toggle),
|
|
|
|
gtk_bin_get_child (GTK_BIN (toggle)));
|
2007-10-17 22:36:12 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (toggle), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2008-03-13 00:58:28 +08:00
|
|
|
view = gtk_bin_get_child (GTK_BIN (button));
|
2004-10-12 20:06:50 +08:00
|
|
|
|
|
|
|
signal_name = g_strconcat ("notify::", reverse_prop, NULL);
|
|
|
|
g_signal_connect_object (context, signal_name,
|
|
|
|
G_CALLBACK (gimp_gradient_box_reverse_notify),
|
2006-01-17 18:08:50 +08:00
|
|
|
G_OBJECT (view), 0);
|
2004-10-12 20:06:50 +08:00
|
|
|
g_free (signal_name);
|
|
|
|
|
|
|
|
gimp_gradient_box_reverse_notify (G_OBJECT (context),
|
|
|
|
NULL,
|
2006-01-17 18:08:50 +08:00
|
|
|
GIMP_VIEW (view));
|
2004-10-12 20:06:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2006-01-14 08:09:22 +08:00
|
|
|
gimp_gradient_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
const gchar *reverse_prop)
|
2004-10-12 20:06:50 +08:00
|
|
|
{
|
2005-09-11 04:35:13 +08:00
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
2004-10-12 20:06:50 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return gradient_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_LARGE,
|
2011-04-08 05:48:08 +08:00
|
|
|
reverse_prop,
|
2016-09-17 23:10:20 +08:00
|
|
|
NULL, NULL);
|
2006-01-14 08:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_gradient_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
const gchar *view_type_prop,
|
|
|
|
const gchar *view_size_prop,
|
2011-04-08 05:48:08 +08:00
|
|
|
const gchar *reverse_prop,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2006-01-14 08:09:22 +08:00
|
|
|
{
|
|
|
|
GimpViewType view_type;
|
|
|
|
GimpViewSize view_size;
|
|
|
|
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
g_object_get (context,
|
|
|
|
view_type_prop, &view_type,
|
|
|
|
view_size_prop, &view_size,
|
|
|
|
NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return view_props_connect (gradient_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, view_size,
|
2011-04-08 05:48:08 +08:00
|
|
|
reverse_prop,
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip),
|
2006-01-14 08:09:22 +08:00
|
|
|
context,
|
|
|
|
view_type_prop, view_size_prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* palette boxes */
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
palette_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
GimpViewType view_type,
|
2011-04-08 05:48:08 +08:00
|
|
|
GimpViewSize view_size,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2006-01-14 08:09:22 +08:00
|
|
|
{
|
2004-10-12 20:06:50 +08:00
|
|
|
if (! container)
|
2008-12-20 05:58:17 +08:00
|
|
|
container = gimp_data_factory_get_container (context->gimp->palette_factory);
|
2004-10-12 20:06:50 +08:00
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return gimp_viewable_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, GIMP_VIEW_SIZE_MEDIUM, view_size,
|
2005-09-11 04:35:13 +08:00
|
|
|
"gimp-palette-list|gimp-palette-grid",
|
|
|
|
GIMP_STOCK_PALETTE,
|
2011-04-08 05:48:08 +08:00
|
|
|
_("Open the palette selection dialog"),
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip);
|
2004-10-12 20:06:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2006-01-14 08:09:22 +08:00
|
|
|
gimp_palette_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return palette_box_new (container, context, label, spacing,
|
2011-04-08 05:48:08 +08:00
|
|
|
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_MEDIUM,
|
2016-09-17 23:10:20 +08:00
|
|
|
NULL, NULL);
|
2006-01-14 08:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_palette_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
const gchar *view_type_prop,
|
2011-04-08 05:48:08 +08:00
|
|
|
const gchar *view_size_prop,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2004-10-12 20:06:50 +08:00
|
|
|
{
|
2006-01-14 08:09:22 +08:00
|
|
|
GimpViewType view_type;
|
|
|
|
GimpViewSize view_size;
|
|
|
|
|
2005-09-11 04:35:13 +08:00
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
2004-10-12 20:06:50 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
g_object_get (context,
|
|
|
|
view_type_prop, &view_type,
|
|
|
|
view_size_prop, &view_size,
|
|
|
|
NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return view_props_connect (palette_box_new (container, context, label, spacing,
|
2011-04-08 05:48:08 +08:00
|
|
|
view_type, view_size,
|
2016-09-17 23:10:20 +08:00
|
|
|
editor_id, editor_tooltip),
|
2006-01-14 08:09:22 +08:00
|
|
|
context,
|
|
|
|
view_type_prop, view_size_prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* font boxes */
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
font_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
GimpViewType view_type,
|
|
|
|
GimpViewSize view_size)
|
|
|
|
{
|
2004-10-12 20:06:50 +08:00
|
|
|
if (! container)
|
|
|
|
container = context->gimp->fonts;
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return gimp_viewable_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, GIMP_VIEW_SIZE_SMALL, view_size,
|
2005-09-11 04:35:13 +08:00
|
|
|
"gimp-font-list|gimp-font-grid",
|
2016-09-03 21:28:22 +08:00
|
|
|
"gtk-select-font",
|
2011-04-08 05:48:08 +08:00
|
|
|
_("Open the font selection dialog"),
|
2016-09-17 23:10:20 +08:00
|
|
|
NULL, NULL);
|
2005-09-11 04:35:13 +08:00
|
|
|
}
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_font_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return font_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
GIMP_VIEW_TYPE_LIST, GIMP_VIEW_SIZE_SMALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_prop_font_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2006-01-14 08:09:22 +08:00
|
|
|
gint spacing,
|
|
|
|
const gchar *view_type_prop,
|
|
|
|
const gchar *view_size_prop)
|
|
|
|
{
|
|
|
|
GimpViewType view_type;
|
|
|
|
GimpViewSize view_size;
|
|
|
|
|
|
|
|
g_return_val_if_fail (container == NULL || GIMP_IS_CONTAINER (container),
|
|
|
|
NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
|
|
|
g_object_get (context,
|
|
|
|
view_type_prop, &view_type,
|
|
|
|
view_size_prop, &view_size,
|
|
|
|
NULL);
|
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
return view_props_connect (font_box_new (container, context, label, spacing,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, view_size),
|
|
|
|
context,
|
|
|
|
view_type_prop, view_size_prop);
|
|
|
|
}
|
|
|
|
|
2005-09-11 04:35:13 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_viewable_box_new (GimpContainer *container,
|
|
|
|
GimpContext *context,
|
2010-11-02 21:05:47 +08:00
|
|
|
const gchar *label,
|
2005-09-11 04:35:13 +08:00
|
|
|
gint spacing,
|
2005-10-31 10:12:40 +08:00
|
|
|
GimpViewType view_type,
|
2015-01-10 06:47:13 +08:00
|
|
|
GimpViewSize button_view_size,
|
2005-09-11 04:35:13 +08:00
|
|
|
GimpViewSize view_size,
|
|
|
|
const gchar *dialog_identifier,
|
2014-05-07 21:30:38 +08:00
|
|
|
const gchar *dialog_icon_name,
|
2011-04-08 05:48:08 +08:00
|
|
|
const gchar *dialog_tooltip,
|
2016-09-17 23:10:20 +08:00
|
|
|
const gchar *editor_id,
|
|
|
|
const gchar *editor_tooltip)
|
2005-09-11 04:35:13 +08:00
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *button;
|
2010-11-02 21:05:47 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *l;
|
2013-06-04 16:19:54 +08:00
|
|
|
GtkWidget *entry_hbox = NULL;
|
2005-09-11 04:35:13 +08:00
|
|
|
GtkWidget *entry;
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, spacing);
|
2004-10-12 20:06:50 +08:00
|
|
|
|
|
|
|
button = gimp_viewable_button_new (container, context,
|
2006-01-14 08:09:22 +08:00
|
|
|
view_type, button_view_size, view_size, 1,
|
2010-03-01 06:20:57 +08:00
|
|
|
gimp_dialog_factory_get_singleton (),
|
2005-09-11 04:35:13 +08:00
|
|
|
dialog_identifier,
|
2014-05-07 21:30:38 +08:00
|
|
|
dialog_icon_name,
|
2005-09-11 04:35:13 +08:00
|
|
|
dialog_tooltip);
|
|
|
|
|
2013-06-04 16:19:54 +08:00
|
|
|
gimp_view_renderer_set_size_full (GIMP_VIEW (GIMP_VIEWABLE_BUTTON (button)->view)->renderer,
|
|
|
|
button_view_size, button_view_size, 1);
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
g_object_set_data (G_OBJECT (hbox), "viewable-button", button);
|
|
|
|
|
2004-10-12 20:06:50 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2010-11-02 21:05:47 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
if (label)
|
|
|
|
{
|
|
|
|
l = gtk_label_new_with_mnemonic (label);
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (l), 0.0);
|
2010-11-02 21:05:47 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), l, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (l);
|
|
|
|
}
|
|
|
|
|
2013-06-04 16:19:54 +08:00
|
|
|
if (editor_id)
|
|
|
|
{
|
|
|
|
entry_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, spacing);
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), entry_hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (entry_hbox);
|
|
|
|
}
|
|
|
|
|
2005-09-11 04:35:13 +08:00
|
|
|
entry = gimp_container_entry_new (container, context, view_size, 1);
|
|
|
|
|
2004-10-12 20:06:50 +08:00
|
|
|
/* set a silly smally size request on the entry to disable
|
|
|
|
* GtkEntry's minimal width of 150 pixels.
|
|
|
|
*/
|
2010-12-10 06:45:00 +08:00
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (entry), 4);
|
2013-06-04 16:19:54 +08:00
|
|
|
|
|
|
|
if (entry_hbox)
|
|
|
|
gtk_box_pack_start (GTK_BOX (entry_hbox), entry, TRUE, TRUE, 0);
|
|
|
|
else
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), entry, label ? FALSE : TRUE, FALSE, 0);
|
|
|
|
|
2004-10-12 20:06:50 +08:00
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
2011-04-08 05:48:08 +08:00
|
|
|
if (editor_id)
|
|
|
|
{
|
|
|
|
GtkWidget *edit_button;
|
|
|
|
GtkWidget *image;
|
|
|
|
|
|
|
|
edit_button = gtk_button_new ();
|
|
|
|
gtk_button_set_relief (GTK_BUTTON (edit_button), GTK_RELIEF_NONE);
|
2013-06-04 16:19:54 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (entry_hbox), edit_button, FALSE, FALSE, 0);
|
2011-04-08 05:48:08 +08:00
|
|
|
gtk_widget_show (edit_button);
|
|
|
|
|
2016-09-17 23:10:20 +08:00
|
|
|
if (editor_tooltip)
|
|
|
|
gimp_help_set_help_data (edit_button, editor_tooltip, NULL);
|
|
|
|
|
2016-09-05 08:51:25 +08:00
|
|
|
image = gtk_image_new_from_icon_name (GTK_STOCK_EDIT,
|
2014-05-07 21:30:38 +08:00
|
|
|
GTK_ICON_SIZE_BUTTON);
|
2011-04-08 05:48:08 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 1.0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (edit_button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (button),
|
|
|
|
"gimp-viewable-box-editor",
|
|
|
|
g_strdup (editor_id),
|
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
|
|
|
g_signal_connect (edit_button, "clicked",
|
|
|
|
G_CALLBACK (gimp_viewable_box_edit_clicked),
|
|
|
|
button);
|
|
|
|
}
|
|
|
|
|
2004-10-12 20:06:50 +08:00
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
2006-01-14 08:09:22 +08:00
|
|
|
static GtkWidget *
|
|
|
|
view_props_connect (GtkWidget *box,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *view_type_prop,
|
|
|
|
const gchar *view_size_prop)
|
|
|
|
{
|
|
|
|
GtkWidget *button = g_object_get_data (G_OBJECT (box), "viewable-button");
|
|
|
|
|
2015-12-29 03:04:29 +08:00
|
|
|
if (view_type_prop)
|
|
|
|
gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
|
|
|
|
view_type_prop, "popup-view-type");
|
|
|
|
|
|
|
|
if (view_size_prop)
|
|
|
|
gimp_config_connect_full (G_OBJECT (context), G_OBJECT (button),
|
|
|
|
view_size_prop, "popup-view-size");
|
2006-01-14 08:09:22 +08:00
|
|
|
|
|
|
|
return box;
|
|
|
|
}
|
|
|
|
|
2011-04-08 05:48:08 +08:00
|
|
|
static void
|
|
|
|
gimp_viewable_box_edit_clicked (GtkWidget *widget,
|
|
|
|
GimpViewableButton *button)
|
|
|
|
{
|
|
|
|
const gchar *editor_id = g_object_get_data (G_OBJECT (button),
|
|
|
|
"gimp-viewable-box-editor");
|
|
|
|
|
2012-01-31 06:52:59 +08:00
|
|
|
gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (button->context->gimp)),
|
|
|
|
button->context->gimp,
|
|
|
|
gimp_dialog_factory_get_singleton (),
|
|
|
|
gtk_widget_get_screen (widget),
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (widget),
|
2012-01-31 06:52:59 +08:00
|
|
|
editor_id);
|
2011-04-08 05:48:08 +08:00
|
|
|
}
|
|
|
|
|
2004-10-12 20:06:50 +08:00
|
|
|
static void
|
|
|
|
gimp_gradient_box_reverse_notify (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpView *view)
|
|
|
|
{
|
|
|
|
GimpViewRendererGradient *rendergrad;
|
|
|
|
gboolean reverse;
|
|
|
|
|
|
|
|
rendergrad = GIMP_VIEW_RENDERER_GRADIENT (view->renderer);
|
|
|
|
|
|
|
|
g_object_get (object, "gradient-reverse", &reverse, NULL);
|
|
|
|
|
|
|
|
gimp_view_renderer_gradient_set_reverse (rendergrad, reverse);
|
|
|
|
}
|