2001-06-26 20:09:43 +08:00
|
|
|
/* 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 <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-08-17 22:27:31 +08:00
|
|
|
#include "gui-types.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpcontext.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "display/gimpdisplay-foreach.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "display/gimpdisplayshell-scale.h"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "display/gimpdisplayshell-selection.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "info-dialog.h"
|
|
|
|
#include "info-window.h"
|
|
|
|
#include "view-commands.h"
|
|
|
|
|
|
|
|
#include "gimprc.h"
|
|
|
|
#include "nav_window.h"
|
|
|
|
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
#define return_if_no_display(gdisp, data) \
|
|
|
|
gdisp = gimp_context_get_display (gimp_get_user_context (GIMP (data))); \
|
|
|
|
if (! gdisp) \
|
|
|
|
return
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-11-02 17:31:21 +08:00
|
|
|
view_zoom_in_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell), GIMP_ZOOM_IN);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-02 17:31:21 +08:00
|
|
|
view_zoom_out_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell), GIMP_ZOOM_OUT);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
void
|
|
|
|
view_zoom_fit_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
gimp_display_shell_scale_fit (GIMP_DISPLAY_SHELL (gdisp->shell));
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
void
|
|
|
|
view_zoom_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (gdisp->shell), action);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_dot_for_dot_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scale_set_dot_for_dot (GIMP_DISPLAY_SHELL (gdisp->shell),
|
|
|
|
GTK_CHECK_MENU_ITEM (widget)->active);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_info_window_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (! gimprc.info_window_follows_mouse)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
if (! shell->info_dialog)
|
|
|
|
shell->info_dialog = info_window_create (gdisp);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
info_dialog_popup (shell->info_dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
info_window_follow_auto (gdisp->gimage->gimp);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_nav_window_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (gimprc.nav_window_per_display)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
if (! shell->nav_dialog)
|
|
|
|
shell->nav_dialog = nav_dialog_create (gdisp);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
nav_dialog_popup (shell->nav_dialog);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nav_dialog_follow_auto ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_toggle_selection_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gint new_val;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
new_val = GTK_CHECK_MENU_ITEM (widget)->active;
|
|
|
|
|
|
|
|
/* hidden == TRUE corresponds to the menu toggle being FALSE */
|
2001-11-11 07:03:22 +08:00
|
|
|
if (new_val == shell->select->hidden)
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_shell_selection_toggle (shell->select);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-16 23:08:59 +08:00
|
|
|
gimp_display_shell_flush (shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_toggle_layer_boundary_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gint new_val;
|
|
|
|
return_if_no_display (gdisp, data);
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
|
|
|
new_val = GTK_CHECK_MENU_ITEM (widget)->active;
|
|
|
|
|
|
|
|
/* hidden == TRUE corresponds to the menu toggle being FALSE */
|
|
|
|
if (new_val == shell->select->layer_hidden)
|
|
|
|
{
|
|
|
|
gimp_display_shell_selection_toggle_layer (shell->select);
|
|
|
|
|
|
|
|
gimp_display_shell_flush (shell);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_toggle_rulers_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (! GTK_CHECK_MENU_ITEM (widget)->active)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (shell->origin))
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_widget_hide (shell->origin);
|
|
|
|
gtk_widget_hide (shell->hrule);
|
|
|
|
gtk_widget_hide (shell->vrule);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (shell->origin->parent));
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
if (! GTK_WIDGET_VISIBLE (shell->origin))
|
2001-06-26 20:09:43 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_widget_show (shell->origin);
|
|
|
|
gtk_widget_show (shell->hrule);
|
|
|
|
gtk_widget_show (shell->vrule);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (shell->origin->parent));
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_toggle_statusbar_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (! GTK_CHECK_MENU_ITEM (widget)->active)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (shell->statusarea))
|
|
|
|
gtk_widget_hide (shell->statusarea);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
if (! GTK_WIDGET_VISIBLE (shell->statusarea))
|
|
|
|
gtk_widget_show (shell->statusarea);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_toggle_guides_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
gboolean old_val;
|
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
old_val = gdisp->draw_guides;
|
|
|
|
gdisp->draw_guides = GTK_CHECK_MENU_ITEM (widget)->active;
|
|
|
|
|
|
|
|
if ((old_val != gdisp->draw_guides) && gdisp->gimage->guides)
|
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_expose_full (GIMP_DISPLAY_SHELL (gdisp->shell));
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_flush (gdisp);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_snap_to_guides_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
gdisp->snap_to_guides = GTK_CHECK_MENU_ITEM (widget)->active;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_new_view_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_create_display (gdisp->gimage->gimp, gdisp->gimage, gdisp->scale);
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
view_shrink_wrap_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2001-10-17 19:33:43 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-10-29 19:47:11 +08:00
|
|
|
return_if_no_display (gdisp, data);
|
2001-06-26 20:09:43 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_scale_shrink_wrap (GIMP_DISPLAY_SHELL (gdisp->shell));
|
2001-06-26 20:09:43 +08:00
|
|
|
}
|