mirror of https://github.com/GNOME/gimp.git
app: use gimp_prop_enum_radio_frame_new() in GimpDesaturateTool
and remove tons of code that was needed to update the old widget.
This commit is contained in:
parent
6940c00774
commit
38e771eea3
|
@ -20,8 +20,6 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
@ -51,12 +49,6 @@ static GeglNode * gimp_desaturate_tool_get_operation (GimpImageMapTool *im_too
|
|||
gchar **undo_desc);
|
||||
static void gimp_desaturate_tool_dialog (GimpImageMapTool *im_tool);
|
||||
|
||||
static void gimp_desaturate_tool_config_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
GimpDesaturateTool *desaturate_tool);
|
||||
static void gimp_desaturate_tool_mode_changed (GtkWidget *button,
|
||||
GimpDesaturateTool *desaturate_tool);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpDesaturateTool, gimp_desaturate_tool,
|
||||
GIMP_TYPE_IMAGE_MAP_TOOL)
|
||||
|
@ -104,9 +96,8 @@ gimp_desaturate_tool_initialize (GimpTool *tool,
|
|||
GimpDisplay *display,
|
||||
GError **error)
|
||||
{
|
||||
GimpDesaturateTool *desaturate_tool = GIMP_DESATURATE_TOOL (tool);
|
||||
GimpImage *image = gimp_display_get_image (display);
|
||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||
GimpImage *image = gimp_display_get_image (display);
|
||||
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
||||
|
||||
if (! drawable)
|
||||
return FALSE;
|
||||
|
@ -118,15 +109,7 @@ gimp_desaturate_tool_initialize (GimpTool *tool,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (desaturate_tool->button),
|
||||
desaturate_tool->config->mode);
|
||||
|
||||
return TRUE;
|
||||
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
||||
}
|
||||
|
||||
static GeglNode *
|
||||
|
@ -134,19 +117,11 @@ gimp_desaturate_tool_get_operation (GimpImageMapTool *image_map_tool,
|
|||
GObject **config,
|
||||
gchar **undo_desc)
|
||||
{
|
||||
GimpDesaturateTool *desaturate_tool = GIMP_DESATURATE_TOOL (image_map_tool);
|
||||
|
||||
desaturate_tool->config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG, NULL);
|
||||
|
||||
g_signal_connect_object (desaturate_tool->config, "notify",
|
||||
G_CALLBACK (gimp_desaturate_tool_config_notify),
|
||||
G_OBJECT (desaturate_tool), 0);
|
||||
|
||||
*config = G_OBJECT (desaturate_tool->config);
|
||||
*config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG, NULL);
|
||||
|
||||
return gegl_node_new_child (NULL,
|
||||
"operation", "gimp:desaturate",
|
||||
"config", desaturate_tool->config,
|
||||
"config", *config,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
@ -158,51 +133,14 @@ gimp_desaturate_tool_get_operation (GimpImageMapTool *image_map_tool,
|
|||
static void
|
||||
gimp_desaturate_tool_dialog (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
GimpDesaturateTool *desaturate_tool = GIMP_DESATURATE_TOOL (image_map_tool);
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *frame;
|
||||
|
||||
main_vbox = gimp_image_map_tool_dialog_get_vbox (image_map_tool);
|
||||
|
||||
/* The table containing sliders */
|
||||
frame = gimp_enum_radio_frame_new (GIMP_TYPE_DESATURATE_MODE,
|
||||
gtk_label_new (_("Choose shade of gray based on:")),
|
||||
G_CALLBACK (gimp_desaturate_tool_mode_changed),
|
||||
desaturate_tool,
|
||||
&desaturate_tool->button);
|
||||
|
||||
frame = gimp_prop_enum_radio_frame_new (image_map_tool->config, "mode",
|
||||
_("Choose shade of gray based on:"),
|
||||
0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_desaturate_tool_config_notify (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
GimpDesaturateTool *desaturate_tool)
|
||||
{
|
||||
GimpDesaturateConfig *config = GIMP_DESATURATE_CONFIG (object);
|
||||
|
||||
if (! desaturate_tool->button)
|
||||
return;
|
||||
|
||||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (desaturate_tool->button),
|
||||
config->mode);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_desaturate_tool_mode_changed (GtkWidget *button,
|
||||
GimpDesaturateTool *desaturate_tool)
|
||||
{
|
||||
GimpDesaturateConfig *config = desaturate_tool->config;
|
||||
GimpDesaturateMode mode;
|
||||
|
||||
mode = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
|
||||
"gimp-item-data"));
|
||||
|
||||
if (config->mode != mode)
|
||||
{
|
||||
g_object_set (config,
|
||||
"mode", mode,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,7 @@ typedef struct _GimpDesaturateToolClass GimpDesaturateToolClass;
|
|||
|
||||
struct _GimpDesaturateTool
|
||||
{
|
||||
GimpImageMapTool parent_instance;
|
||||
|
||||
GimpDesaturateConfig *config;
|
||||
|
||||
/* dialog */
|
||||
GtkWidget *button;
|
||||
GimpImageMapTool parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpDesaturateToolClass
|
||||
|
|
Loading…
Reference in New Issue