Commit 360f8321 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/Makefile.am removed.

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

	* app/Makefile.am
	* app/qmask.[ch]: removed.

	* app/core/gimpimage.[ch]: added "qmask_changed" signal and
	gimp_image_[set|get]_qmask_state().

	* app/display/Makefile.am
	* app/display/gimpdisplayshell-qmask.[ch]: put the stuff here.

	* app/display/gimpdisplayshell-handlers.[ch]: new files: handlers
	for GimpImage signals handled by GimpDisplayShell.

	* app/display/gimpdisplay-handlers.c: removed some of them here.
	Don't include any GimpDisplayShell stuff any more.

	* app/display/gimpdisplay.c: no need to update the qmask buttons
	in gimp_display_flush_whenever().

	* app/display/gimpdisplayshell.c: call gimp_display_shell_connect()
	and disconnect().
parent 7125fdbc
2001-11-10 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/qmask.[ch]: removed.
* app/core/gimpimage.[ch]: added "qmask_changed" signal and
gimp_image_[set|get]_qmask_state().
* app/display/Makefile.am
* app/display/gimpdisplayshell-qmask.[ch]: put the stuff here.
* app/display/gimpdisplayshell-handlers.[ch]: new files: handlers
for GimpImage signals handled by GimpDisplayShell.
* app/display/gimpdisplay-handlers.c: removed some of them here.
Don't include any GimpDisplayShell stuff any more.
* app/display/gimpdisplay.c: no need to update the qmask buttons
in gimp_display_flush_whenever().
* app/display/gimpdisplayshell.c: call gimp_display_shell_connect()
and disconnect().
2001-11-10 Michael Natterer <mitch@gimp.org>
* app/qmask.c: fixed qmask callbacks to check if the toggle is
......
......@@ -20,8 +20,6 @@ gimp_SOURCES = @STRIP_BEGIN@ \
nav_window.h \
ops_buttons.c \
ops_buttons.h \
qmask.c \
qmask.h \
undo_history.c \
undo_history.h \
##
......
......@@ -19,15 +19,13 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets/widgets-types.h"
#include "display-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
......@@ -35,15 +33,14 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "widgets/gimpcolorpanel.h"
#include "app_procs.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "floating_sel.h"
#include "qmask.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
......@@ -61,7 +58,8 @@ struct _EditQmaskOptions
};
/* Prototypes */
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
......@@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
/* Actual code */
static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
void
qmask_buttons_update (GimpDisplay *gdisp)
{
GimpDisplayShell *shell;
g_assert (gdisp);
g_assert (gdisp->gimage);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
{
/* Disable toggle from doing anything */
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
qmask_deactivate_callback,
gdisp);
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
qmask_activate_callback,
gdisp);
/* Change the state of the buttons */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
gdisp->gimage->qmask_state);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
! gdisp->gimage->qmask_state);
/* Enable toggle again */
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
qmask_deactivate_callback,
gdisp);
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
qmask_activate_callback,
gdisp);
}
}
/* public functions */
gboolean
qmask_button_press_callback (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
gdisp = (GimpDisplay *) data;
gdisp = shell->gdisp;
if ((event->type == GDK_2BUTTON_PRESS) &&
(event->button == 1))
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
edit_qmask_channel_query (gdisp);
......@@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
}
void
qmask_deactivate_callback (GtkWidget *widget,
GimpDisplay *gdisp)
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *gmask;
GimpChannel *mask;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (!gdisp->gimage->qmask_state)
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
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 */
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimage_mask_load (gimage, gmask);
gimp_image_remove_channel (gimage, gmask);
gimage_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gdisp->gimage->qmask_state = FALSE;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (gmask)
if (mask)
gdisplays_flush ();
}
}
void
qmask_activate_callback (GtkWidget *widget,
GimpDisplay *gdisp)
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *gmask;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (gdisp->gimage->qmask_state)
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
if (mask)
{
gimage->qmask_state = TRUE;
/* if the user was clever and created his own */
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
......@@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
floating_sel_to_layer (layer);
}
gmask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, gmask, 0);
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, gmask, 0);
gimp_channel_set_color (gmask, &color);
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);
gimp_channel_set_color (mask, &color);
gimp_object_set_name (GIMP_OBJECT (mask), "Qmask");
gimage_mask_none (gimage); /* Clear the selection */
}
undo_push_qmask (gimage);
undo_push_group_end (gimage);
gdisp->gimage->qmask_state = TRUE;
gimp_image_set_qmask_state (gimage, TRUE);
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
g_signal_connect (G_OBJECT (gmask), "removed",
g_signal_connect (G_OBJECT (mask), "removed",
G_CALLBACK (qmask_removed_callback),
gdisp);
}
}
/* private functions */
static void
edit_qmask_channel_query (GimpDisplay *gdisp)
{
......@@ -399,3 +336,37 @@ edit_qmask_query_cancel_callback (GtkWidget *widget,
gtk_widget_destroy (options->query_box);
g_free (options);
}
static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
}
......@@ -19,15 +19,13 @@
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets/widgets-types.h"
#include "display-types.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
......@@ -35,15 +33,14 @@
#include "core/gimpimage.h"
#include "core/gimpimage-mask.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
#include "display/gimpdisplayshell.h"
#include "widgets/gimpcolorpanel.h"
#include "app_procs.h"
#include "gimpdisplay.h"
#include "gimpdisplay-foreach.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-qmask.h"
#include "floating_sel.h"
#include "qmask.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
......@@ -61,7 +58,8 @@ struct _EditQmaskOptions
};
/* Prototypes */
/* local function prototypes */
static void edit_qmask_channel_query (GimpDisplay *gdisp);
static void edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data);
......@@ -74,93 +72,18 @@ static void qmask_color_changed (GimpColorButton *button,
static void qmask_removed_callback (GtkObject *qmask,
gpointer data);
/* Actual code */
static void
qmask_query_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (data), &color);
gimp_rgb_set_alpha (&color, adjustment->value / 100.0);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (data), &color);
}
static void
qmask_color_changed (GimpColorButton *button,
gpointer data)
{
GtkAdjustment *adj = GTK_ADJUSTMENT (data);
GimpRGB color;
gimp_color_button_get_color (button, &color);
gtk_adjustment_set_value (adj, color.a * 100.0);
}
static void
qmask_removed_callback (GtkObject *qmask,
gpointer data)
{
GimpDisplay *gdisp = (GimpDisplay *) data;
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
void
qmask_buttons_update (GimpDisplay *gdisp)
{
GimpDisplayShell *shell;
g_assert (gdisp);
g_assert (gdisp->gimage);
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (shell->qmaskon)->active)
{
/* Disable toggle from doing anything */
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskoff),
qmask_deactivate_callback,
gdisp);
g_signal_handlers_block_by_func (G_OBJECT (shell->qmaskon),
qmask_activate_callback,
gdisp);
/* Change the state of the buttons */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskon),
gdisp->gimage->qmask_state);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (shell->qmaskoff),
! gdisp->gimage->qmask_state);
/* Enable toggle again */
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskoff),
qmask_deactivate_callback,
gdisp);
g_signal_handlers_unblock_by_func (G_OBJECT (shell->qmaskon),
qmask_activate_callback,
gdisp);
}
}
/* public functions */
gboolean
qmask_button_press_callback (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
gimp_display_shell_qmask_button_press (GtkWidget *widget,
GdkEventButton *event,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
gdisp = (GimpDisplay *) data;
gdisp = shell->gdisp;
if ((event->type == GDK_2BUTTON_PRESS) &&
(event->button == 1))
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
{
edit_qmask_channel_query (gdisp);
......@@ -171,65 +94,74 @@ qmask_button_press_callback (GtkWidget *widget,
}
void
qmask_deactivate_callback (GtkWidget *widget,
GimpDisplay *gdisp)
gimp_display_shell_qmask_off_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *gmask;
GimpChannel *mask;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (!gdisp->gimage->qmask_state)
if (! gimp_image_get_qmask_state (gimage))
return; /* if already set do nothing */
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
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 */
* call the qmask_removed_callback() which will set
* the qmask_state to FALSE
*/
undo_push_qmask (gimage);
gimage_mask_load (gimage, gmask);
gimp_image_remove_channel (gimage, gmask);
gimage_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
undo_push_group_end (gimage);
}
gdisp->gimage->qmask_state = FALSE;
gimp_image_set_qmask_state (gdisp->gimage, FALSE);
if (gmask)
if (mask)
gdisplays_flush ();
}
}
void
qmask_activate_callback (GtkWidget *widget,
GimpDisplay *gdisp)
gimp_display_shell_qmask_on_toggled (GtkWidget *widget,
GimpDisplayShell *shell)
{
GimpDisplay *gdisp;
GimpImage *gimage;
GimpChannel *gmask;
GimpChannel *mask;
GimpLayer *layer;
GimpRGB color;
gdisp = shell->gdisp;
if (GTK_TOGGLE_BUTTON (widget)->active)
{
gimage = gdisp->gimage;
if (gdisp->gimage->qmask_state)
if (gimp_image_get_qmask_state (gimage))
return; /* if already set, do nothing */
/* Set the defaults */
color = gimage->qmask_color;
gmask = gimp_image_get_channel_by_name (gimage, "Qmask");
mask = gimp_image_get_channel_by_name (gimage, "Qmask");
if (gmask)
if (mask)
{
gimage->qmask_state = TRUE;
/* if the user was clever and created his own */
gimp_image_set_qmask_state (gimage, TRUE);
return;
}
......@@ -244,38 +176,43 @@ qmask_activate_callback (GtkWidget *widget,
floating_sel_to_layer (layer);
}
gmask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, gmask, 0);
mask = gimp_channel_new (gimage,
gimage->width,
gimage->height,
"Qmask",
&color);
gimp_image_add_channel (gimage, mask, 0);
gimp_drawable_fill_by_type (GIMP_DRAWABLE (gmask),
gimp_drawable_fill_by_type (GIMP_DRAWABLE (mask),
gimp_get_user_context (gimage->gimp),
TRANSPARENT_FILL);
}
else /* if selection */
{
gmask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, gmask, 0);
gimp_channel_set_color (gmask, &color);
gimp_object_set_name (GIMP_OBJECT (gmask), "Qmask");
mask = gimp_channel_copy (gimp_image_get_mask (gimage), TRUE);
gimp_image_add_channel (gimage, mask, 0);