mirror of https://github.com/GNOME/gimp.git
app: add gimp_rectangle_options_connect() and _disconnect()
and use the new function from GimpRectangleTool. We need this also in the new GimpToolWidget-base code, so it has to move out of gimprectangletool.c.
This commit is contained in:
parent
1ebf905ed3
commit
2f0963589b
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimptooloptions.h"
|
||||
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
|
@ -1057,6 +1058,112 @@ gimp_rectangle_options_gui (GimpToolOptions *tool_options)
|
|||
return vbox;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rectangle_options_connect (GimpRectangleOptions *options,
|
||||
GimpImage *image,
|
||||
GCallback shrink_callback,
|
||||
gpointer shrink_object)
|
||||
{
|
||||
GimpRectangleOptionsPrivate *options_private;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
||||
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (shrink_callback != NULL);
|
||||
g_return_if_fail (shrink_object != NULL);
|
||||
|
||||
options_private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
if (options_private->fixed_width_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->fixed_width_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_width (image));
|
||||
}
|
||||
|
||||
if (options_private->fixed_height_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->fixed_height_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_height (image));
|
||||
}
|
||||
|
||||
if (options_private->x_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->x_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_width (image));
|
||||
}
|
||||
|
||||
if (options_private->y_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->y_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_height (image));
|
||||
}
|
||||
|
||||
if (options_private->width_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->width_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_width (image));
|
||||
}
|
||||
|
||||
if (options_private->height_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->height_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_height (image));
|
||||
}
|
||||
|
||||
if (options_private->auto_shrink_button)
|
||||
{
|
||||
g_signal_connect_swapped (options_private->auto_shrink_button, "clicked",
|
||||
shrink_callback,
|
||||
shrink_object);
|
||||
|
||||
gtk_widget_set_sensitive (options_private->auto_shrink_button, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rectangle_options_disconnect (GimpRectangleOptions *options,
|
||||
GCallback shrink_callback,
|
||||
gpointer shrink_object)
|
||||
{
|
||||
GimpRectangleOptionsPrivate *options_private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options));
|
||||
g_return_if_fail (shrink_callback != NULL);
|
||||
g_return_if_fail (shrink_object != NULL);
|
||||
|
||||
options_private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
|
||||
|
||||
if (options_private->auto_shrink_button)
|
||||
{
|
||||
gtk_widget_set_sensitive (options_private->auto_shrink_button, FALSE);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (options_private->auto_shrink_button,
|
||||
shrink_callback,
|
||||
shrink_object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rectangle_options_fixed_rule_active:
|
||||
* @rectangle_options:
|
||||
|
|
|
@ -145,6 +145,14 @@ GType gimp_rectangle_options_interface_get_type (void) G_GNUC_CONST;
|
|||
|
||||
GtkWidget * gimp_rectangle_options_gui (GimpToolOptions *tool_options);
|
||||
|
||||
void gimp_rectangle_options_connect (GimpRectangleOptions *options,
|
||||
GimpImage *image,
|
||||
GCallback shrink_callback,
|
||||
gpointer shrink_object);
|
||||
void gimp_rectangle_options_disconnect (GimpRectangleOptions *options,
|
||||
GCallback shrink_callback,
|
||||
gpointer shrink_object);
|
||||
|
||||
gboolean gimp_rectangle_options_fixed_rule_active (GimpRectangleOptions *rectangle_options,
|
||||
GimpRectangleFixedRule fixed_rule);
|
||||
|
||||
|
|
|
@ -1983,16 +1983,8 @@ static void
|
|||
gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
|
||||
GimpDisplay *display)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpRectangleOptionsPrivate *options_private;
|
||||
GimpImage *image;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
||||
options_private =
|
||||
GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (gimp_tool_get_options (tool));
|
||||
|
||||
image = gimp_display_get_image (display);
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpRectangleOptions *options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (rect_tool);
|
||||
|
||||
tool->display = display;
|
||||
|
||||
|
@ -2010,80 +2002,17 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool,
|
|||
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->display);
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
if (options_private->fixed_width_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->fixed_width_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_width (image));
|
||||
}
|
||||
|
||||
if (options_private->fixed_height_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->fixed_height_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_height (image));
|
||||
}
|
||||
|
||||
if (options_private->x_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->x_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_width (image));
|
||||
}
|
||||
|
||||
if (options_private->y_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->y_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_height (image));
|
||||
}
|
||||
|
||||
if (options_private->width_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->width_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_width (image));
|
||||
}
|
||||
|
||||
if (options_private->height_entry)
|
||||
{
|
||||
GtkWidget *entry = options_private->height_entry;
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0,
|
||||
0, gimp_image_get_height (image));
|
||||
}
|
||||
|
||||
if (options_private->auto_shrink_button)
|
||||
{
|
||||
g_signal_connect_swapped (options_private->auto_shrink_button, "clicked",
|
||||
G_CALLBACK (gimp_rectangle_tool_auto_shrink),
|
||||
rect_tool);
|
||||
|
||||
gtk_widget_set_sensitive (options_private->auto_shrink_button, TRUE);
|
||||
}
|
||||
gimp_rectangle_options_connect (options,
|
||||
gimp_display_get_image (display),
|
||||
G_CALLBACK (gimp_rectangle_tool_auto_shrink),
|
||||
rect_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rectangle_tool_halt (GimpRectangleTool *rect_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpRectangleOptionsPrivate *options_private;
|
||||
|
||||
options_private =
|
||||
GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (gimp_tool_get_options (tool));
|
||||
GimpTool *tool = GIMP_TOOL (rect_tool);
|
||||
GimpRectangleOptions *options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (rect_tool);
|
||||
|
||||
if (tool->display)
|
||||
{
|
||||
|
@ -2104,14 +2033,9 @@ gimp_rectangle_tool_halt (GimpRectangleTool *rect_tool)
|
|||
|
||||
gimp_rectangle_tool_set_function (rect_tool, GIMP_RECTANGLE_TOOL_INACTIVE);
|
||||
|
||||
if (options_private->auto_shrink_button)
|
||||
{
|
||||
gtk_widget_set_sensitive (options_private->auto_shrink_button, FALSE);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (options_private->auto_shrink_button,
|
||||
gimp_rectangle_tool_auto_shrink,
|
||||
rect_tool);
|
||||
}
|
||||
gimp_rectangle_options_disconnect (options,
|
||||
G_CALLBACK (gimp_rectangle_tool_auto_shrink),
|
||||
rect_tool);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
Loading…
Reference in New Issue