Commit bf6e5a4b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

replaced the QMask radio buttons ba a single check button. Still needs

2001-11-29  Michael Natterer  <mitch@gimp.org>

	* app/display/gimpdisplayshell.[ch]: replaced the QMask radio
	buttons ba a single check button. Still needs some tuning.

	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell-qmask.[ch]: changed accordingly.

	* app/tools/gimptool.[ch]: added "gboolean handle_empty_image" to
	the GimpTool structure.

	* app/tools/gimpmovetool.c: set it to TRUE.

	* app/tools/gimpfuzzyselecttool.c: don't gimp_[set|unset]_busy()
	while calculating the selection but set the busy cursor on the
	display manually (we have the pointer grabbed anyway).

	* app/display/gimpdisplayshell-callbacks.c: don't check for
	GIMP_IS_MODE_TOOL(active_tool) but look at
	active_tool->handle_empty_image. Removed the checks for
	GIMP_IS_FUZZY_SELECT_TOOL(active_tool) because fuzzy_select
	doesn't set GIMP busy while it's active any more.

	* app/tools/transform_options.[ch]
	* app/tools/gimptransformtool.c
	* app/tools/gimprotatetool.c
	* app/tools/gimpscaletool.c: added widgets for the transform tools'
	constraints (one more #51108 issue fixed).

	* app/tools/gimperasertool.c: cosmetic.

	* app/widgets/gimpdockbook.c: don't hardcode GtkNotebook's
	tab_border to 0 but add a style property for it...

	* themes/Default/gtkrc: ...and set it to 0 here.
parent ea1173c6
2001-11-29 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell.[ch]: replaced the QMask radio
buttons ba a single check button. Still needs some tuning.
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell-qmask.[ch]: changed accordingly.
* app/tools/gimptool.[ch]: added "gboolean handle_empty_image" to
the GimpTool structure.
* app/tools/gimpmovetool.c: set it to TRUE.
* app/tools/gimpfuzzyselecttool.c: don't gimp_[set|unset]_busy()
while calculating the selection but set the busy cursor on the
display manually (we have the pointer grabbed anyway).
* app/display/gimpdisplayshell-callbacks.c: don't check for
GIMP_IS_MODE_TOOL(active_tool) but look at
active_tool->handle_empty_image. Removed the checks for
GIMP_IS_FUZZY_SELECT_TOOL(active_tool) because fuzzy_select
doesn't set GIMP busy while it's active any more.
* app/tools/transform_options.[ch]
* app/tools/gimptransformtool.c
* app/tools/gimprotatetool.c
* app/tools/gimpscaletool.c: added widgets for the transform tools'
constraints (one more #51108 issue fixed).
* app/tools/gimperasertool.c: cosmetic.
* app/widgets/gimpdockbook.c: don't hardcode GtkNotebook's
tab_border to 0 but add a style property for it...
* themes/Default/gtkrc: ...and set it to 0 here.
2001-11-29 Sven Neumann <sven@gimp.org>
* libgimpbase/gimpenv.c
......
......@@ -94,47 +94,8 @@ gimp_display_shell_qmask_button_press (GtkWidget *widget,
}
void
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
void
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
......@@ -144,10 +105,10 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
gdisp = shell->gdisp;
gimage = gdisp->gimage;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
......@@ -208,6 +169,33 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
G_CALLBACK (qmask_removed_callback),
gdisp);
}
else
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
......
......@@ -94,47 +94,8 @@ gimp_display_shell_qmask_button_press (GtkWidget *widget,
}
void
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
void
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
......@@ -144,10 +105,10 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
gdisp = shell->gdisp;
gimage = gdisp->gimage;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
......@@ -208,6 +169,33 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
G_CALLBACK (qmask_removed_callback),
gdisp);
}
else
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
......
......@@ -94,47 +94,8 @@ gimp_display_shell_qmask_button_press (GtkWidget *widget,
}
void
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
void
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
......@@ -144,10 +105,10 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
gdisp = shell->gdisp;
gimage = gdisp->gimage;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
......@@ -208,6 +169,33 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
G_CALLBACK (qmask_removed_callback),
gdisp);
}
else
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
......
......@@ -94,47 +94,8 @@ gimp_display_shell_qmask_button_press (GtkWidget *widget,
}
void
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *mask;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
void
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
gimp_display_shell_qmask_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
......@@ -144,10 +105,10 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
gdisp = shell->gdisp;
gimage = gdisp->gimage;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
......@@ -208,6 +169,33 @@ gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
G_CALLBACK (qmask_removed_callback),
gdisp);
}
else
{
gimage = gdisp->gimage;
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (mask)
{
undo_push_group_start (gimage, QMASK_UNDO);
/* push the undo here since removing the mask will
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (mask)
gdisplays_flush ();
}
}
......
......@@ -29,6 +29,7 @@
#include "display-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
......@@ -36,7 +37,6 @@
#include "tools/tools-types.h"
#include "tools/gimpfuzzyselecttool.h"
#include "tools/gimpmovetool.h"
#include "tools/tool_manager.h"
......@@ -383,6 +383,24 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
}
break;
case GDK_FOCUS_CHANGE:
{
GdkEventFocus *fevent;
fevent = (GdkEventFocus *) event;
if (fevent->in)
GTK_WIDGET_SET_FLAGS (canvas, GTK_HAS_FOCUS);
else
GTK_WIDGET_UNSET_FLAGS (canvas, GTK_HAS_FOCUS);
/* stop the signal because otherwise gtk+ exposes the whole
* canvas to get the non-existant focus indicator drawn
*/
return TRUE;
}
break;
case GDK_ENTER_NOTIFY:
{
GdkEventCrossing *cevent;
......@@ -495,7 +513,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
/* FIXME!!! This code is ugly */
if (active_tool && (! gimp_image_is_empty (gdisp->gimage) ||
GIMP_IS_MOVE_TOOL (active_tool) /* EEK */))
active_tool->handle_empty_image))
{
if (active_tool->auto_snap_to)
{
......@@ -518,8 +536,8 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
{
tool_manager_initialize_active (gdisp->gimage->gimp, gdisp);
}
else if ((gimp_image_active_drawable (gdisp->gimage) !=
active_tool->drawable) &&
else if ((active_tool->drawable !=
gimp_image_active_drawable (gdisp->gimage)) &&
! active_tool->preserve)
{
/* create a new one, deleting the current
......@@ -569,16 +587,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* ugly side condition: all operations which set busy cursors are
* invoked on BUTTON_RELEASE, thus no new BUTTON_PRESS events are
* accepted while Gimp is busy, thus it should be safe to block
* BUTTON_RELEASE. --Mitch
*
* ugly: fuzzy_select sets busy cursors while ACTIVE.
*/
if (gdisp->gimage->gimp->busy &&
! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) &&
active_tool->state == ACTIVE))
if (gdisp->gimage->gimp->busy)
return TRUE;
switch (bevent->button)
......@@ -595,8 +604,8 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
gtk_grab_remove (canvas);
if (active_tool && (GIMP_IS_MOVE_TOOL (active_tool) ||
! gimp_image_is_empty (gdisp->gimage)))
if (active_tool && (! gimp_image_is_empty (gdisp->gimage) ||
active_tool->handle_empty_image))
{
if (active_tool->state == ACTIVE)
{
......@@ -699,16 +708,7 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
mevent = (GdkEventMotion *) event;
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
/* for the same reason we block BUTTON_RELEASE,
* we block MOTION_NOTIFY. --Mitch
*
* ugly: fuzzy_select sets busy cursors while ACTIVE.
*/
if (gdisp->gimage->gimp->busy &&
! (GIMP_IS_FUZZY_SELECT_TOOL (active_tool) &&
active_tool->state == ACTIVE))
if (gdisp->gimage->gimp->busy)
return TRUE;
/* Ask for the pointer position, but ignore it except for cursor
......@@ -729,9 +729,11 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
gimp_display_shell_check_device_cursor (shell);
}
active_tool = tool_manager_get_active (gdisp->gimage->gimp);
if ((state & GDK_BUTTON1_MASK) &&
active_tool && (! gimp_image_is_empty (gdisp->gimage) ||
GIMP_IS_MOVE_TOOL (active_tool)))
active_tool->handle_empty_image))
{
if (active_tool->state == ACTIVE)
{
......@@ -954,7 +956,8 @@ gimp_display_shell_canvas_events (GtkWidget *canvas,
if (active_tool)
{
if (! gimp_image_is_empty (gdisp->gimage) &&
if ((! gimp_image_is_empty (gdisp->gimage) ||
active_tool->handle_empty_image) &&
! (state & (GDK_BUTTON1_MASK |
GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK)))
......@@ -1007,8 +1010,9 @@ gimp_display_shell_hruler_button_press (GtkWidget *widget,
GimpToolInfo *tool_info;
GimpTool *active_tool;
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gdisp->gimage->gimp->tool_info_list,
"gimp:move_tool");
if (tool_info)
{
......@@ -1045,8 +1049,9 @@ gimp_display_shell_vruler_button_press (GtkWidget *widget,
GimpToolInfo *tool_info;
GimpTool *active_tool;
tool_info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
GIMP_TYPE_MOVE_TOOL);
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gdisp->gimage->gimp->tool_info_list,
"gimp:move_tool");
if (tool_info)
{
......
......@@ -198,8 +198,7 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->hsb = NULL;
shell->vsb = NULL;
shell->qmaskoff = NULL;
shell->qmaskon = NULL;
shell->qmask = NULL;
shell->hrule = NULL;
shell->vrule = NULL;
shell->origin = NULL;
......@@ -336,7 +335,6 @@ gimp_display_shell_new (GimpDisplay *gdisp)
GtkWidget *image;
GtkWidget *label_frame;
GtkWidget *nav_ebox;
GSList *group = NULL;
gint image_width, image_height;
gint n_width, n_height;
gint s_width, s_height;
......@@ -467,8 +465,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
* | |
* | +-- lower_hbox
* | |
* | +-- qmaskoff
* | +-- qmaskon
* | +-- qmask
* | +-- hscrollbar
* | +-- navbutton
* |
......@@ -509,7 +506,7 @@ gimp_display_shell_new (GimpDisplay *gdisp)
gtk_box_pack_start (GTK_BOX (upper_hbox), right_vbox, FALSE, FALSE, 0);
gtk_widget_show (right_vbox);
/* the hbox containing qmask buttons, vertical scrollbar and nav button */
/* the hbox containing qmask button, vertical scrollbar and nav button */
lower_hbox = gtk_hbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (disp_vbox), lower_hbox, FALSE, FALSE, 0);
gtk_widget_show (lower_hbox);
......@@ -625,50 +622,38 @@ gimp_display_shell_new (GimpDisplay *gdisp)
/* create the contents of the lower_hbox *********************************/
/* the qmask buttons */
shell->qmaskoff = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (shell->qmaskoff));
gtk_widget_set_usize (GTK_WIDGET (shell->qmaskoff), 16, 16);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (shell->qmaskoff), FALSE);
GTK_WIDGET_UNSET_FLAGS (shell->qmaskoff, GTK_CAN_FOCUS);