gimp/app/widgets/gimptoolbox-indicator-area.c
Michael Natterer b62f8e9a75 To be multihead safe, each new window or menu needs to be associated with
2003-11-08  Michael Natterer  <mitch@gimp.org>

	To be multihead safe, each new window or menu needs to be
	associated with a GdkScreen or it will pop up on the default
	screen.

	* libgimpwidgets/gimpquerybox.[ch]
	* app/display/gimpdisplayshell-layer-select.[ch]
	* app/widgets/widgets-types.h
	* app/widgets/gimpitemfactory.[ch]
	* app/widgets/gimpitemtreeview.[ch]
	* app/widgets/gimptemplateview.[ch]
	* app/widgets/gimptooldialog.[ch]
	* app/widgets/gimpviewabledialog.[ch]
	* app/gui/channels-commands.[ch]
	* app/gui/color-notebook.[ch]
	* app/gui/convert-dialog.[ch]
	* app/gui/edit-commands.[ch]
	* app/gui/grid-dialog.[ch]
	* app/gui/image-commands.[ch]
	* app/gui/info-dialog.[ch]
	* app/gui/layers-commands.[ch]
	* app/gui/offset-dialog.[ch]
	* app/gui/resize-dialog.[ch]
	* app/gui/stroke-dialog.[ch]
	* app/gui/templates-commands.[ch]
	* app/gui/vectors-commands.[ch]: added "GtkWidget *parent"
	paramaters to all functions which create menus, popups or windows
	and pass "parent" to gimp_dialog_new() or one of the various
	wrappers around it. As a side effect, this fixes bug #61092.

	* app/widgets/gimpdialogfactory.[ch]: added "GdkScreen *screen"
	instead of "parent" here since there are no possible parent
	windows on startup.

	* app/display/gimpdisplayshell-callbacks.c
	(gimp_display_shell_origin_button_press): added a quick hack to
	send a display to another screen: click the origin button with the
	middle mouse button.

	* app/display/gimpdisplayshell.c
	(gimp_display_shell_screen_changed): don't chain up
	undonditionally (don't crash).

	* libgimpwidgets/gimpdialog.c (gimp_dialog_new_valist): set the
	dialog's screen from a non-GtkWidget parent widget. The rest of
	non-window parent widget handling is still unimplemented.

	* libgimpwidgets/gimpcolorbutton.c
	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimpcolorpanel.c
	* app/widgets/gimpcomponenteditor.c
	* app/widgets/gimpcontainereditor.c
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainerpopup.c
	* app/widgets/gimpcontainertreeview.c
	* app/widgets/gimpdatafactoryview.c
	* app/widgets/gimpdevicestatus.c
	* app/widgets/gimpdockable.c
	* app/widgets/gimpdrawabletreeview.c
	* app/widgets/gimperrorconsole.c
	* app/widgets/gimpgradienteditor.c
	* app/widgets/gimphelp.c
	* app/widgets/gimppaletteeditor.c
	* app/widgets/gimppreview-popup.c
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimpsessioninfo.c
	* app/widgets/gimptoolbox-color-area.c
	* app/widgets/gimptoolbox-indicator-area.c
	* app/widgets/gimptoolbox.c
	* app/widgets/gimptooloptionseditor.c
	* app/widgets/gimpvectorstreeview.c
	* app/widgets/gimpwidgets-utils.c
	* app/display/gimpdisplayshell-scale.c
	* app/display/gimpnavigationview.c
	* app/gui/module-browser.c
	* app/gui/dialogs-commands.c
	* app/gui/dialogs-constructors.c
	* app/gui/drawable-commands.c
	* app/gui/file-commands.c
	* app/gui/file-new-dialog.c
	* app/gui/file-save-dialog.c
	* app/gui/gradient-editor-commands.c
	* app/gui/gui-vtable.c
	* app/gui/gui.c
	* app/gui/info-window.c
	* app/gui/palette-import-dialog.c
	* app/gui/palettes-commands.c
	* app/gui/qmask-commands.c
	* app/gui/select-commands.c
	* app/gui/tool-options-commands.c
	* app/gui/view-commands.c
	* app/tools/gimpcolorpickertool.c
	* app/tools/gimpcroptool.c
	* app/tools/gimpimagemaptool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimptransformtool.c
	* plug-ins/FractalExplorer/FractalExplorer.c
	* plug-ins/gfig/gfig.c
	* plug-ins/gflare/gflare.c: changed accordingly. Changed all
	menu_position funcs to place the menu on the right screen.
2003-11-08 15:32:38 +00:00

224 lines
6.5 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpbrush.h"
#include "core/gimpcontext.h"
#include "core/gimpgradient.h"
#include "core/gimppattern.h"
#include "gimpdialogfactory.h"
#include "gimpdnd.h"
#include "gimppreview.h"
#include "gimptoolbox.h"
#include "gimptoolbox-indicator-area.h"
#include "gimp-intl.h"
#define CELL_SIZE 23 /* The size of the previews */
#define GRAD_CELL_WIDTH 48 /* The width of the gradient preview */
#define GRAD_CELL_HEIGHT 12 /* The height of the gradient preview */
#define CELL_PADDING 2 /* How much between brush and pattern cells */
static void
brush_preview_clicked (GtkWidget *widget,
GdkModifierType state,
GimpToolbox *toolbox)
{
gimp_dialog_factory_dialog_raise (GIMP_DOCK (toolbox)->dialog_factory,
gtk_widget_get_screen (widget),
"gimp-brush-grid", -1);
}
static void
brush_preview_drop_brush (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContext *context;
context = GIMP_CONTEXT (data);
gimp_context_set_brush (context, GIMP_BRUSH (viewable));
}
static void
pattern_preview_clicked (GtkWidget *widget,
GdkModifierType state,
GimpToolbox *toolbox)
{
gimp_dialog_factory_dialog_raise (GIMP_DOCK (toolbox)->dialog_factory,
gtk_widget_get_screen (widget),
"gimp-pattern-grid", -1);
}
static void
pattern_preview_drop_pattern (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContext *context;
context = GIMP_CONTEXT (data);
gimp_context_set_pattern (context, GIMP_PATTERN (viewable));
}
static void
gradient_preview_clicked (GtkWidget *widget,
GdkModifierType state,
GimpToolbox *toolbox)
{
gimp_dialog_factory_dialog_raise (GIMP_DOCK (toolbox)->dialog_factory,
gtk_widget_get_screen (widget),
"gimp-gradient-list", -1);
}
static void
gradient_preview_drop_gradient (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
GimpContext *context;
context = GIMP_CONTEXT (data);
gimp_context_set_gradient (context, GIMP_GRADIENT (viewable));
}
/* public functions */
GtkWidget *
gimp_toolbox_indicator_area_create (GimpToolbox *toolbox)
{
GimpContext *context;
GtkWidget *indicator_table;
GtkWidget *brush_preview;
GtkWidget *pattern_preview;
GtkWidget *gradient_preview;
g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
context = GIMP_DOCK (toolbox)->context;
indicator_table = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (indicator_table), CELL_PADDING);
gtk_table_set_col_spacings (GTK_TABLE (indicator_table), CELL_PADDING);
/* brush preview */
brush_preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_brush (context)),
CELL_SIZE, CELL_SIZE, 0,
FALSE, TRUE, TRUE);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), brush_preview,
0, 1, 0, 1);
gtk_widget_show (brush_preview);
gimp_help_set_help_data (brush_preview,
_("The active brush.\n"
"Click to open the Brush Dialog."), NULL);
g_signal_connect_object (context, "brush_changed",
G_CALLBACK (gimp_preview_set_viewable),
brush_preview,
G_CONNECT_SWAPPED);
g_signal_connect (brush_preview, "clicked",
G_CALLBACK (brush_preview_clicked),
toolbox);
gimp_dnd_viewable_dest_add (brush_preview,
GIMP_TYPE_BRUSH,
brush_preview_drop_brush,
context);
/* pattern preview */
pattern_preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_pattern (context)),
CELL_SIZE, CELL_SIZE, 0,
FALSE, TRUE, TRUE);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), pattern_preview,
1, 2, 0, 1);
gtk_widget_show (pattern_preview);
gimp_help_set_help_data (pattern_preview,
_("The active pattern.\n"
"Click to open the Pattern Dialog."), NULL);
g_signal_connect_object (context, "pattern_changed",
G_CALLBACK (gimp_preview_set_viewable),
pattern_preview,
G_CONNECT_SWAPPED);
g_signal_connect (pattern_preview, "clicked",
G_CALLBACK (pattern_preview_clicked),
toolbox);
gimp_dnd_viewable_dest_add (pattern_preview,
GIMP_TYPE_PATTERN,
pattern_preview_drop_pattern,
context);
/* gradient preview */
gradient_preview =
gimp_preview_new_full (GIMP_VIEWABLE (gimp_context_get_gradient (context)),
GRAD_CELL_WIDTH, GRAD_CELL_HEIGHT, 0,
FALSE, TRUE, TRUE);
gtk_table_attach_defaults (GTK_TABLE (indicator_table), gradient_preview,
0, 2, 1, 2);
gtk_widget_show (gradient_preview);
gimp_help_set_help_data (gradient_preview,
_("The active gradient.\n"
"Click to open the Gradient Dialog."), NULL);
g_signal_connect_object (context, "gradient_changed",
G_CALLBACK (gimp_preview_set_viewable),
gradient_preview,
G_CONNECT_SWAPPED);
g_signal_connect (gradient_preview, "clicked",
G_CALLBACK (gradient_preview_clicked),
toolbox);
gimp_dnd_viewable_dest_add (gradient_preview,
GIMP_TYPE_GRADIENT,
gradient_preview_drop_gradient,
context);
gtk_widget_show (indicator_table);
return indicator_table;
}