1999-08-13 06:21:04 +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.
|
|
|
|
*/
|
2000-12-14 21:52:16 +08:00
|
|
|
|
1999-09-06 08:07:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-08-24 06:47:36 +08:00
|
|
|
#include <stdlib.h>
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2002-01-30 22:54:27 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning GTK_DISABLE_DEPRECATED
|
|
|
|
#endif
|
|
|
|
#undef GTK_DISABLE_DEPRECATED
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
#include "widgets/widgets-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpimage.h"
|
2001-06-18 21:10:03 +08:00
|
|
|
#include "core/gimplist.h"
|
|
|
|
|
2002-04-15 01:28:58 +08:00
|
|
|
#include "file/file-utils.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:18:57 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "display/gimpdisplayshell-scroll.h"
|
|
|
|
#include "display/gimpdisplayshell-scale.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
#include "widgets/gimpnavigationpreview.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-05-14 05:51:20 +08:00
|
|
|
#include "app_procs.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "nav_window.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "app_procs.h"
|
1999-09-05 06:27:20 +08:00
|
|
|
#include "gimprc.h"
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1999-08-13 06:21:04 +08:00
|
|
|
|
1999-10-22 03:35:35 +08:00
|
|
|
#define PREVIEW_MASK GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_KEY_PRESS_MASK | \
|
|
|
|
GDK_KEY_RELEASE_MASK | \
|
|
|
|
GDK_POINTER_MOTION_MASK
|
|
|
|
|
1999-08-13 06:21:04 +08:00
|
|
|
|
|
|
|
/* Navigation preview sizes */
|
|
|
|
#define NAV_PREVIEW_WIDTH 112
|
|
|
|
#define NAV_PREVIEW_HEIGHT 112
|
|
|
|
#define BORDER_PEN_WIDTH 3
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
#define MAX_SCALE_BUF 20
|
1999-08-28 03:07:21 +08:00
|
|
|
|
1999-09-02 06:39:44 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
NAV_WINDOW,
|
|
|
|
NAV_POPUP
|
|
|
|
} NavWinType;
|
1999-08-28 03:07:21 +08:00
|
|
|
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
struct _NavigationDialog
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
NavWinType ptype;
|
|
|
|
|
|
|
|
GtkWidget *shell;
|
|
|
|
|
|
|
|
GtkWidget *new_preview;
|
|
|
|
|
|
|
|
GtkWidget *preview_frame;
|
|
|
|
GtkWidget *zoom_label;
|
|
|
|
GtkObject *zoom_adjustment;
|
|
|
|
GtkWidget *preview;
|
|
|
|
GimpDisplay *gdisp; /* I'm not happy 'bout this one */
|
|
|
|
GdkGC *gc;
|
|
|
|
gint dispx; /* x pos of top left corner of display area */
|
|
|
|
gint dispy; /* y pos of top left corner of display area */
|
|
|
|
gint dispwidth; /* width of display area */
|
|
|
|
gint dispheight; /* height of display area */
|
|
|
|
|
|
|
|
gboolean sq_grabbed; /* In the process of moving the preview square */
|
|
|
|
gint motion_offsetx;
|
|
|
|
gint motion_offsety;
|
|
|
|
|
|
|
|
gint pwidth; /* real preview width */
|
|
|
|
gint pheight; /* real preview height */
|
|
|
|
gint imagewidth; /* width of the real image */
|
|
|
|
gint imageheight; /* height of real image */
|
|
|
|
gdouble ratio;
|
|
|
|
gint nav_preview_width;
|
|
|
|
gint nav_preview_height;
|
|
|
|
gboolean block_adj_sig;
|
|
|
|
gboolean frozen; /* Has the dialog been frozen ? */
|
|
|
|
guint idle_id;
|
1999-08-13 06:21:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
static NavigationDialog * nav_dialog_new (GimpDisplay *gdisp,
|
2001-06-18 21:10:03 +08:00
|
|
|
NavWinType ptype);
|
2001-10-29 19:47:11 +08:00
|
|
|
static gchar * nav_dialog_title (GimpDisplay *gdisp);
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static GtkWidget * nav_create_button_area (NavigationDialog *nav_dialog);
|
|
|
|
static void nav_dialog_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void nav_dialog_disp_area (NavigationDialog *nav_dialog,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-06-18 21:10:03 +08:00
|
|
|
static void nav_dialog_draw_sqr (NavigationDialog *nav_dialog,
|
|
|
|
gboolean undraw,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
|
|
|
static gboolean nav_dialog_preview_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void nav_dialog_idle_update_preview (NavigationDialog *nav_dialog);
|
|
|
|
static void nav_dialog_update_preview (NavigationDialog *nav_dialog);
|
|
|
|
static void nav_dialog_update_preview_blank (NavigationDialog *nav_dialog);
|
1999-08-24 06:47:36 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void create_preview_widget (NavigationDialog *nav_dialog);
|
|
|
|
static void set_size_data (NavigationDialog *nav_dialog);
|
|
|
|
static void nav_image_need_update (GimpImage *gimage,
|
|
|
|
gpointer data);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void nav_dialog_display_changed (GimpContext *context,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp,
|
2001-06-18 21:10:03 +08:00
|
|
|
gpointer data);
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
static GimpDisplay * nav_dialog_get_gdisp (void);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
static void nav_dialog_grab_pointer (NavigationDialog *nav_dialog,
|
|
|
|
GtkWidget *widget);
|
|
|
|
static void update_zoom_label (NavigationDialog *nav_dialog);
|
|
|
|
static void update_zoom_adjustment (NavigationDialog *nav_dialog);
|
|
|
|
|
|
|
|
|
|
|
|
static NavigationDialog *nav_window_auto = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
1999-08-13 06:21:04 +08:00
|
|
|
|
|
|
|
static void
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_marker_changed (GimpNavigationPreview *nav_preview,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
NavigationDialog *nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble xratio;
|
|
|
|
gdouble yratio;
|
|
|
|
gint xoffset;
|
|
|
|
gint yoffset;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (nav_dialog->gdisp->shell);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
xratio = SCALEFACTOR_X (nav_dialog->gdisp);
|
|
|
|
yratio = SCALEFACTOR_Y (nav_dialog->gdisp);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
xoffset = x * xratio - shell->offset_x;
|
|
|
|
yoffset = y * yratio - shell->offset_y;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scroll (shell, xoffset, yoffset);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-08-10 00:39:08 +08:00
|
|
|
static void
|
|
|
|
nav_dialog_zoom (GimpNavigationPreview *nav_preview,
|
|
|
|
GimpZoomType direction,
|
|
|
|
NavigationDialog *nav_dialog)
|
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (nav_dialog->gdisp->shell);
|
|
|
|
|
|
|
|
gimp_display_shell_scale (shell, direction);
|
2001-08-10 00:39:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nav_dialog_scroll (GimpNavigationPreview *nav_preview,
|
|
|
|
GdkScrollDirection direction,
|
|
|
|
NavigationDialog *nav_dialog)
|
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
GtkAdjustment *adj = NULL;
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (nav_dialog->gdisp->shell);
|
2001-08-10 00:39:08 +08:00
|
|
|
|
|
|
|
g_print ("nav_dialog_scroll(%d)\n", direction);
|
|
|
|
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
case GDK_SCROLL_RIGHT:
|
2001-11-01 05:18:57 +08:00
|
|
|
adj = shell->hsbdata;
|
2001-08-10 00:39:08 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
case GDK_SCROLL_DOWN:
|
2001-11-01 05:18:57 +08:00
|
|
|
adj = shell->vsbdata;
|
2001-08-10 00:39:08 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_assert (adj != NULL);
|
|
|
|
|
2001-08-10 00:39:08 +08:00
|
|
|
value = adj->value;
|
|
|
|
|
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
value -= adj->page_increment / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
value += adj->page_increment / 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
value = CLAMP (value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (adj, value);
|
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *
|
2001-10-29 19:47:11 +08:00
|
|
|
nav_dialog_create (GimpDisplay *gdisp)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
|
|
|
NavigationDialog *nav_dialog;
|
|
|
|
GtkWidget *button_area;
|
|
|
|
GtkWidget *abox;
|
|
|
|
gchar *title;
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
title = nav_dialog_title (gdisp);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog = nav_dialog_new (gdisp, NAV_WINDOW);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->shell = gimp_dialog_new (title, "navigation_dialog",
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/navigation_window.html",
|
|
|
|
GTK_WIN_POS_MOUSE,
|
|
|
|
FALSE, TRUE, TRUE,
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
"_delete_event_",
|
|
|
|
nav_dialog_close_callback,
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog, NULL, NULL, TRUE, TRUE,
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_free (title);
|
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
gtk_dialog_set_has_separator (GTK_DIALOG (nav_dialog->shell), FALSE);
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_widget_hide (GTK_DIALOG (nav_dialog->shell)->action_area);
|
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (nav_dialog->shell),
|
2001-08-30 01:48:28 +08:00
|
|
|
(GWeakNotify) g_free,
|
2001-08-01 17:33:12 +08:00
|
|
|
nav_dialog);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), abox,
|
|
|
|
TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
|
|
|
nav_dialog->preview_frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (nav_dialog->preview_frame),
|
|
|
|
GTK_SHADOW_IN);
|
|
|
|
gtk_container_add (GTK_CONTAINER (abox), nav_dialog->preview_frame);
|
|
|
|
gtk_widget_show (nav_dialog->preview_frame);
|
|
|
|
|
|
|
|
create_preview_widget (nav_dialog);
|
|
|
|
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *preview;
|
|
|
|
|
|
|
|
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), abox,
|
|
|
|
TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (abox);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
|
|
gtk_container_add (GTK_CONTAINER (abox), frame);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
preview = gimp_navigation_preview_new (gdisp->gimage,
|
|
|
|
gimprc.nav_preview_size);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), preview);
|
|
|
|
gtk_widget_show (preview);
|
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (preview), "marker_changed",
|
|
|
|
G_CALLBACK (nav_dialog_marker_changed),
|
|
|
|
nav_dialog);
|
2001-08-10 00:39:08 +08:00
|
|
|
g_signal_connect (G_OBJECT (preview), "zoom",
|
|
|
|
G_CALLBACK (nav_dialog_zoom),
|
|
|
|
nav_dialog);
|
|
|
|
g_signal_connect (G_OBJECT (preview), "scroll",
|
|
|
|
G_CALLBACK (nav_dialog_scroll),
|
|
|
|
nav_dialog);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
nav_dialog->new_preview = preview;
|
|
|
|
}
|
|
|
|
|
|
|
|
button_area = nav_create_button_area (nav_dialog);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox),
|
|
|
|
button_area, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button_area);
|
|
|
|
|
2001-07-25 08:27:41 +08:00
|
|
|
if (! g_object_get_data (G_OBJECT (gdisp->gimage), "nav_handlers_installed"))
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (gdisp->gimage), "dirty",
|
|
|
|
G_CALLBACK (nav_image_need_update),
|
|
|
|
nav_dialog);
|
|
|
|
g_signal_connect (G_OBJECT (gdisp->gimage), "clean",
|
|
|
|
G_CALLBACK (nav_image_need_update),
|
|
|
|
nav_dialog);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (gdisp->gimage), "nav_handlers_installed",
|
2001-07-25 08:27:41 +08:00
|
|
|
nav_dialog);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
return nav_dialog;
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
void
|
2001-10-29 19:47:11 +08:00
|
|
|
nav_dialog_free (GimpDisplay *del_gdisp,
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
/* So this functions works both ways..
|
|
|
|
* it will come in here with nav_dialog == null
|
|
|
|
* if the auto mode is on...
|
|
|
|
*/
|
1999-10-22 03:35:35 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
if (nav_window_auto != NULL)
|
2000-12-15 01:28:38 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog = nav_window_auto;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* Only freeze if we are displaying the image we have deleted */
|
|
|
|
if (nav_dialog->gdisp != del_gdisp)
|
|
|
|
return;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (nav_dialog->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (nav_dialog->idle_id);
|
|
|
|
nav_dialog->idle_id = 0;
|
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gdisp = nav_dialog_get_gdisp ();
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (gdisp)
|
|
|
|
{
|
|
|
|
nav_dialog_display_changed (NULL, gdisp, nav_window_auto);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Clear window and freeze */
|
|
|
|
nav_dialog->frozen = TRUE;
|
|
|
|
nav_dialog_update_preview_blank (nav_window_auto);
|
|
|
|
gtk_window_set_title (GTK_WINDOW (nav_window_auto->shell),
|
|
|
|
_("Navigation: No Image"));
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_widget_set_sensitive (nav_window_auto->shell, FALSE);
|
|
|
|
nav_window_auto->gdisp = NULL;
|
|
|
|
gtk_widget_hide (GTK_WIDGET (nav_window_auto->shell));
|
|
|
|
}
|
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
return;
|
|
|
|
}
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (nav_dialog->idle_id)
|
2000-12-14 21:52:16 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
g_source_remove (nav_dialog->idle_id);
|
|
|
|
nav_dialog->idle_id = 0;
|
2000-12-14 21:52:16 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_widget_destroy (nav_dialog->shell);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
void
|
|
|
|
nav_dialog_popup (NavigationDialog *nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog)
|
|
|
|
return;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! GTK_WIDGET_VISIBLE (nav_dialog->shell))
|
|
|
|
{
|
|
|
|
gtk_widget_show (nav_dialog->shell);
|
|
|
|
|
|
|
|
nav_dialog_idle_update_preview (nav_dialog);
|
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gdk_window_raise (nav_dialog->shell->window);
|
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
void
|
|
|
|
nav_dialog_follow_auto (void)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
context = gimp_get_user_context (the_gimp);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gdisp = gimp_context_get_display (context);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! gdisp)
|
|
|
|
return;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_window_auto)
|
|
|
|
{
|
|
|
|
nav_window_auto = nav_dialog_create (gdisp);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (context), "display_changed",
|
|
|
|
G_CALLBACK (nav_dialog_display_changed),
|
|
|
|
nav_window_auto);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_popup (nav_window_auto);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_widget_set_sensitive (nav_window_auto->shell, TRUE);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_window_auto->frozen = FALSE;
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
void
|
|
|
|
nav_dialog_update_window_marker (NavigationDialog *nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
/* So this functions works both ways..
|
|
|
|
* it will come in here with info_win == null
|
|
|
|
* if the auto mode is on...
|
|
|
|
*/
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog && nav_window_auto)
|
|
|
|
{
|
|
|
|
nav_dialog = nav_window_auto;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (nav_dialog->frozen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nav_dialog_update_window_marker (nav_window_auto);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (! nav_dialog)
|
1999-08-24 06:47:36 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
return;
|
1999-08-24 06:47:36 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! GTK_WIDGET_VISIBLE (nav_dialog->shell))
|
|
|
|
return;
|
1999-08-24 06:47:36 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
update_zoom_label (nav_dialog);
|
|
|
|
update_zoom_adjustment (nav_dialog);
|
1999-08-24 06:47:36 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* Undraw old size */
|
|
|
|
nav_dialog_draw_sqr (nav_dialog,
|
|
|
|
FALSE,
|
|
|
|
nav_dialog->dispx, nav_dialog->dispy,
|
|
|
|
nav_dialog->dispwidth, nav_dialog->dispheight);
|
1999-08-24 06:47:36 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* Update to new size */
|
|
|
|
nav_dialog_disp_area (nav_dialog, nav_dialog->gdisp);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* and redraw */
|
|
|
|
nav_dialog_draw_sqr (nav_dialog,
|
|
|
|
FALSE,
|
|
|
|
nav_dialog->dispx, nav_dialog->dispy,
|
|
|
|
nav_dialog->dispwidth, nav_dialog->dispheight);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
void
|
|
|
|
nav_dialog_preview_resized (NavigationDialog *nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog)
|
|
|
|
return;
|
1999-08-21 07:20:23 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* force regeneration of the widgets
|
|
|
|
* bit of a fiddle... could cause if the image really is 1x1
|
|
|
|
* but the preview would not really matter in that case.
|
|
|
|
*/
|
|
|
|
nav_dialog->imagewidth = 1;
|
|
|
|
nav_dialog->imageheight = 1;
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->nav_preview_width =
|
|
|
|
(gimprc.nav_preview_size < 0 || gimprc.nav_preview_size > 256) ?
|
|
|
|
NAV_PREVIEW_WIDTH : gimprc.nav_preview_size;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->nav_preview_height =
|
|
|
|
(gimprc.nav_preview_size < 0 || gimprc.nav_preview_size > 256) ?
|
|
|
|
NAV_PREVIEW_HEIGHT : gimprc.nav_preview_size;
|
2000-12-15 06:29:49 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_update_window_marker (nav_dialog);
|
|
|
|
}
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
void
|
|
|
|
nav_popup_click_handler (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
2001-11-01 05:18:57 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDisplayShell *shell;
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *nav_dialog;
|
|
|
|
gint x, y;
|
|
|
|
gint x_org, y_org;
|
|
|
|
gint scr_w, scr_h;
|
2000-12-15 23:54:17 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
gdisp = GIMP_DISPLAY (data);
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
bevent = (GdkEventButton *) event;
|
2000-12-15 23:54:17 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
if (! shell->nav_popup)
|
1999-10-21 06:15:13 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
GtkWidget *frame;
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
shell->nav_popup = nav_dialog = nav_dialog_new (gdisp, NAV_POPUP);
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->shell = gtk_window_new (GTK_WINDOW_POPUP);
|
|
|
|
gtk_widget_set_events (nav_dialog->shell, PREVIEW_MASK);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (nav_dialog->shell),
|
2001-08-30 01:48:28 +08:00
|
|
|
(GWeakNotify) g_free,
|
2001-08-01 17:33:12 +08:00
|
|
|
nav_dialog);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
|
|
|
gtk_container_add (GTK_CONTAINER (nav_dialog->shell), frame);
|
|
|
|
gtk_widget_show (frame);
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->preview_frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (nav_dialog->preview_frame),
|
|
|
|
GTK_SHADOW_IN);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), nav_dialog->preview_frame);
|
|
|
|
gtk_widget_show (nav_dialog->preview_frame);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
create_preview_widget (nav_dialog);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_widget_set_extension_events (nav_dialog->preview,
|
|
|
|
GDK_EXTENSION_EVENTS_ALL);
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_disp_area (nav_dialog, nav_dialog->gdisp);
|
1999-10-21 06:15:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
nav_dialog = shell->nav_popup;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
gtk_widget_hide (nav_dialog->shell);
|
|
|
|
|
|
|
|
nav_dialog_disp_area (nav_dialog, nav_dialog->gdisp);
|
|
|
|
nav_dialog_update_preview (nav_dialog);
|
1999-10-21 06:15:13 +08:00
|
|
|
}
|
1999-08-21 08:18:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* decide where to put the popup */
|
|
|
|
gdk_window_get_origin (widget->window, &x_org, &y_org);
|
|
|
|
|
|
|
|
scr_w = gdk_screen_width ();
|
|
|
|
scr_h = gdk_screen_height ();
|
|
|
|
|
|
|
|
x = x_org + bevent->x - nav_dialog->dispx -
|
|
|
|
((nav_dialog->dispwidth - BORDER_PEN_WIDTH + 1) * 0.5) - 2;
|
|
|
|
y = y_org + bevent->y - nav_dialog->dispy -
|
|
|
|
((nav_dialog->dispheight - BORDER_PEN_WIDTH + 1)* 0.5) - 2;
|
|
|
|
|
|
|
|
/* If the popup doesn't fit into the screen, we have a problem.
|
|
|
|
* We move the popup onscreen and risk that the pointer is not
|
|
|
|
* in the square representing the viewable area anymore. Moving
|
|
|
|
* the pointer will make the image scroll by a large amount,
|
|
|
|
* but then it works as usual. Probably better than a popup that
|
|
|
|
* is completely unusable in the lower right of the screen.
|
|
|
|
*
|
|
|
|
* Warping the pointer would be another solution ...
|
|
|
|
*/
|
|
|
|
x = (x < 0) ? 0 : x;
|
|
|
|
y = (y < 0) ? 0 : y;
|
|
|
|
x = (x + nav_dialog->pwidth > scr_w) ? scr_w - nav_dialog->pwidth - 2: x;
|
|
|
|
y = (y + nav_dialog->pheight > scr_h) ? scr_h - nav_dialog->pheight - 2: y;
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_window_move (GTK_WINDOW (nav_dialog->shell), x, y);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
gtk_widget_show (nav_dialog->shell);
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gdk_flush();
|
|
|
|
|
|
|
|
/* fill in then set up handlers for mouse motion etc */
|
|
|
|
nav_dialog->motion_offsetx =
|
|
|
|
(nav_dialog->dispwidth - BORDER_PEN_WIDTH + 1) * 0.5;
|
|
|
|
|
|
|
|
nav_dialog->motion_offsety =
|
|
|
|
(nav_dialog->dispheight - BORDER_PEN_WIDTH + 1) * 0.5;
|
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (nav_dialog->preview))
|
|
|
|
nav_dialog_grab_pointer (nav_dialog, nav_dialog->preview);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static NavigationDialog *
|
2001-10-29 19:47:11 +08:00
|
|
|
nav_dialog_new (GimpDisplay *gdisp,
|
|
|
|
NavWinType ptype)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
|
|
|
NavigationDialog *nav_dialog;
|
|
|
|
|
|
|
|
nav_dialog = g_new0 (NavigationDialog, 1);
|
|
|
|
|
|
|
|
nav_dialog->ptype = ptype;
|
|
|
|
nav_dialog->shell = NULL;
|
|
|
|
nav_dialog->preview = NULL;
|
|
|
|
nav_dialog->zoom_label = NULL;
|
|
|
|
nav_dialog->zoom_adjustment = NULL;
|
|
|
|
nav_dialog->gdisp = gdisp;
|
|
|
|
nav_dialog->dispx = -1;
|
|
|
|
nav_dialog->dispy = -1;
|
|
|
|
nav_dialog->dispwidth = -1;
|
|
|
|
nav_dialog->dispheight = -1;
|
|
|
|
nav_dialog->imagewidth = -1;
|
|
|
|
nav_dialog->imageheight = -1;
|
|
|
|
nav_dialog->sq_grabbed = FALSE;
|
|
|
|
nav_dialog->ratio = 1.0;
|
|
|
|
|
|
|
|
nav_dialog->nav_preview_width =
|
|
|
|
(gimprc.nav_preview_size < 0 || gimprc.nav_preview_size > 256) ?
|
|
|
|
NAV_PREVIEW_WIDTH : gimprc.nav_preview_size;
|
|
|
|
|
|
|
|
nav_dialog->nav_preview_height =
|
|
|
|
(gimprc.nav_preview_size < 0 || gimprc.nav_preview_size > 256) ?
|
|
|
|
NAV_PREVIEW_HEIGHT : gimprc.nav_preview_size;
|
|
|
|
|
|
|
|
nav_dialog->block_adj_sig = FALSE;
|
|
|
|
nav_dialog->frozen = FALSE;
|
|
|
|
nav_dialog->idle_id = 0;
|
|
|
|
|
|
|
|
return nav_dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2001-10-29 19:47:11 +08:00
|
|
|
nav_dialog_title (GimpDisplay *gdisp)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-08-30 01:48:28 +08:00
|
|
|
gchar *basename;
|
2001-06-18 21:10:03 +08:00
|
|
|
gchar *title;
|
|
|
|
|
2002-04-15 01:28:58 +08:00
|
|
|
basename = file_utils_uri_to_utf8_basename (gimp_image_get_uri (gdisp->gimage));
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
title = g_strdup_printf (_("Navigation: %s-%d.%d"),
|
|
|
|
basename,
|
|
|
|
gimp_image_get_ID (gdisp->gimage),
|
|
|
|
gdisp->instance);
|
|
|
|
|
2001-08-30 01:48:28 +08:00
|
|
|
g_free (basename);
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nav_dialog_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
NavigationDialog *nav_dialog;
|
|
|
|
|
|
|
|
nav_dialog = (NavigationDialog *) data;
|
|
|
|
|
|
|
|
gtk_widget_hide (nav_dialog->shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nav_dialog_disp_area (NavigationDialog *nav_dialog,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
GimpImage *gimage;
|
|
|
|
gint newwidth;
|
|
|
|
gint newheight;
|
|
|
|
gdouble xratio;
|
|
|
|
gdouble yratio; /* Screen res ratio */
|
|
|
|
gboolean need_update = FALSE;
|
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
/* Calculate preview size */
|
|
|
|
gimage = gdisp->gimage;
|
|
|
|
|
|
|
|
xratio = SCALEFACTOR_X (gdisp);
|
|
|
|
yratio = SCALEFACTOR_Y (gdisp);
|
|
|
|
|
|
|
|
if (nav_dialog->new_preview)
|
|
|
|
{
|
|
|
|
if (GIMP_PREVIEW (nav_dialog->new_preview)->dot_for_dot !=
|
|
|
|
gdisp->dot_for_dot)
|
|
|
|
gimp_preview_set_dot_for_dot (GIMP_PREVIEW (nav_dialog->new_preview),
|
|
|
|
gdisp->dot_for_dot);
|
|
|
|
|
|
|
|
gimp_navigation_preview_set_marker
|
|
|
|
(GIMP_NAVIGATION_PREVIEW (nav_dialog->new_preview),
|
2001-11-02 17:31:21 +08:00
|
|
|
RINT (shell->offset_x / xratio),
|
|
|
|
RINT (shell->offset_y / yratio),
|
|
|
|
RINT (shell->disp_width / xratio),
|
|
|
|
RINT (shell->disp_height / yratio));
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
nav_dialog->dispx = shell->offset_x * nav_dialog->ratio / xratio + 0.5;
|
|
|
|
nav_dialog->dispy = shell->offset_y * nav_dialog->ratio/yratio + 0.5;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
nav_dialog->dispwidth = (shell->disp_width * nav_dialog->ratio) / xratio + 0.5;
|
|
|
|
nav_dialog->dispheight = (shell->disp_height * nav_dialog->ratio) / yratio + 0.5;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
newwidth = gimage->width;
|
|
|
|
newheight = gimage->height;
|
|
|
|
|
|
|
|
if (! gdisp->dot_for_dot)
|
|
|
|
{
|
|
|
|
newwidth =
|
|
|
|
(newwidth * gdisp->gimage->yresolution) / gdisp->gimage->xresolution;
|
|
|
|
|
|
|
|
nav_dialog->dispx =
|
2001-11-02 17:31:21 +08:00
|
|
|
((shell->offset_x *
|
2001-06-18 21:10:03 +08:00
|
|
|
gdisp->gimage->yresolution * nav_dialog->ratio) /
|
|
|
|
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
|
|
|
|
|
|
|
|
nav_dialog->dispwidth =
|
2001-11-02 17:31:21 +08:00
|
|
|
((shell->disp_width *
|
2001-06-18 21:10:03 +08:00
|
|
|
gdisp->gimage->yresolution * nav_dialog->ratio) /
|
|
|
|
(gdisp->gimage->xresolution * xratio)) + 0.5; /*here*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((nav_dialog->imagewidth > 0 && newwidth != nav_dialog->imagewidth) ||
|
|
|
|
(nav_dialog->imageheight > 0 && newheight != nav_dialog->imageheight))
|
|
|
|
{
|
|
|
|
/* Must change the preview size */
|
|
|
|
|
|
|
|
if (nav_dialog->ptype != NAV_POPUP)
|
|
|
|
{
|
|
|
|
gtk_window_set_focus (GTK_WINDOW (nav_dialog->shell), NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (nav_dialog->preview);
|
|
|
|
create_preview_widget (nav_dialog);
|
|
|
|
|
|
|
|
need_update = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nav_dialog->imagewidth = newwidth;
|
|
|
|
nav_dialog->imageheight = newheight;
|
|
|
|
|
|
|
|
/* Normalise */
|
|
|
|
nav_dialog->dispwidth = MAX (nav_dialog->dispwidth, 2);
|
|
|
|
nav_dialog->dispheight = MAX (nav_dialog->dispheight, 2);
|
|
|
|
|
|
|
|
nav_dialog->dispwidth = MIN (nav_dialog->dispwidth, nav_dialog->pwidth);
|
|
|
|
nav_dialog->dispheight = MIN (nav_dialog->dispheight, nav_dialog->pheight);
|
|
|
|
|
|
|
|
if (need_update)
|
|
|
|
{
|
|
|
|
if (nav_dialog->ptype != NAV_POPUP)
|
|
|
|
{
|
|
|
|
gtk_window_set_focus (GTK_WINDOW (nav_dialog->shell),
|
|
|
|
nav_dialog->preview);
|
|
|
|
|
|
|
|
nav_dialog_idle_update_preview (nav_dialog);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nav_dialog_update_preview (nav_dialog);
|
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_queue_draw (nav_dialog->preview);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nav_dialog_draw_sqr (NavigationDialog *nav_dialog,
|
|
|
|
gboolean undraw,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
|
|
|
{
|
|
|
|
if (! nav_dialog->gc)
|
|
|
|
{
|
|
|
|
if (! GTK_WIDGET_REALIZED (nav_dialog->shell))
|
|
|
|
gtk_widget_realize (nav_dialog->shell);
|
|
|
|
|
|
|
|
nav_dialog->gc = gdk_gc_new (nav_dialog->shell->window);
|
|
|
|
|
|
|
|
gdk_gc_set_function (nav_dialog->gc, GDK_INVERT);
|
|
|
|
gdk_gc_set_line_attributes (nav_dialog->gc, BORDER_PEN_WIDTH,
|
|
|
|
GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (undraw)
|
|
|
|
{
|
|
|
|
if (nav_dialog->dispx != 0 ||
|
|
|
|
nav_dialog->dispy != 0 ||
|
|
|
|
nav_dialog->pwidth != nav_dialog->dispwidth ||
|
|
|
|
nav_dialog->pheight != nav_dialog->dispheight)
|
|
|
|
{
|
|
|
|
/* first undraw from last co-ords */
|
|
|
|
gdk_draw_rectangle (nav_dialog->preview->window, nav_dialog->gc,
|
|
|
|
FALSE,
|
|
|
|
nav_dialog->dispx,
|
|
|
|
nav_dialog->dispy,
|
|
|
|
nav_dialog->dispwidth - BORDER_PEN_WIDTH + 1,
|
|
|
|
nav_dialog->dispheight - BORDER_PEN_WIDTH + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x != 0 || y != 0 ||
|
|
|
|
w != nav_dialog->pwidth || h != nav_dialog->pheight)
|
|
|
|
{
|
|
|
|
gdk_draw_rectangle (nav_dialog->preview->window, nav_dialog->gc,
|
|
|
|
FALSE,
|
|
|
|
x, y,
|
|
|
|
w - BORDER_PEN_WIDTH + 1,
|
|
|
|
h - BORDER_PEN_WIDTH + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
nav_dialog->dispx = x;
|
|
|
|
nav_dialog->dispy = y;
|
|
|
|
nav_dialog->dispwidth = w;
|
|
|
|
nav_dialog->dispheight = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_size_data (NavigationDialog *nav_dialog)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpImage *gimage;
|
|
|
|
gint sel_width;
|
|
|
|
gint sel_height;
|
|
|
|
gint pwidth;
|
|
|
|
gint pheight;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
gdisp = nav_dialog->gdisp;
|
|
|
|
gimage = gdisp->gimage;
|
|
|
|
|
|
|
|
sel_width = gimage->width;
|
|
|
|
sel_height = gimage->height;
|
|
|
|
|
|
|
|
if (! gdisp->dot_for_dot)
|
|
|
|
sel_width =
|
|
|
|
(sel_width * gdisp->gimage->yresolution) / gdisp->gimage->xresolution;
|
|
|
|
|
|
|
|
if (sel_width > sel_height)
|
|
|
|
{
|
|
|
|
pwidth = nav_dialog->nav_preview_width;
|
|
|
|
|
|
|
|
nav_dialog->ratio = (gdouble) pwidth / (gdouble) sel_width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pheight = nav_dialog->nav_preview_height;
|
|
|
|
|
|
|
|
nav_dialog->ratio = (gdouble) pheight / (gdouble) sel_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
pwidth = sel_width * nav_dialog->ratio + 0.5;
|
|
|
|
pheight = sel_height * nav_dialog->ratio + 0.5;
|
|
|
|
|
|
|
|
nav_dialog->pwidth = pwidth;
|
|
|
|
nav_dialog->pheight = pheight;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
create_preview_widget (NavigationDialog *nav_dialog)
|
|
|
|
{
|
|
|
|
GtkWidget *preview;
|
|
|
|
|
|
|
|
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_MASK);
|
|
|
|
GTK_WIDGET_SET_FLAGS (preview, GTK_CAN_FOCUS);
|
|
|
|
gtk_preview_set_dither (GTK_PREVIEW (preview), GDK_RGB_DITHER_MAX);
|
|
|
|
gtk_container_add (GTK_CONTAINER (nav_dialog->preview_frame), preview);
|
|
|
|
gtk_widget_show (preview);
|
|
|
|
|
|
|
|
nav_dialog->preview = preview;
|
|
|
|
|
|
|
|
set_size_data (nav_dialog);
|
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
gtk_preview_size (GTK_PREVIEW (preview),
|
|
|
|
nav_dialog->pwidth, nav_dialog->pheight);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (preview), "event",
|
|
|
|
G_CALLBACK (nav_dialog_preview_events),
|
|
|
|
nav_dialog);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
nav_dialog_update_preview_idle_func (NavigationDialog *nav_dialog)
|
|
|
|
{
|
|
|
|
nav_dialog->idle_id = 0;
|
|
|
|
|
|
|
|
/* If the gdisp has gone then don't do anything in this timer */
|
|
|
|
if (! nav_dialog->gdisp)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
nav_dialog_update_preview (nav_dialog);
|
|
|
|
nav_dialog_disp_area (nav_dialog, nav_dialog->gdisp);
|
|
|
|
gtk_widget_queue_draw (nav_dialog->preview);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nav_dialog_idle_update_preview (NavigationDialog *nav_dialog)
|
|
|
|
{
|
|
|
|
if (nav_dialog->idle_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nav_dialog->idle_id =
|
|
|
|
g_idle_add_full (G_PRIORITY_LOW,
|
|
|
|
(GSourceFunc) nav_dialog_update_preview_idle_func,
|
|
|
|
nav_dialog,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nav_dialog_update_preview (NavigationDialog *nav_dialog)
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
TempBuf *preview_buf;
|
|
|
|
TempBuf *preview_buf_ptr;
|
|
|
|
TempBuf *preview_buf_notdot = NULL;
|
|
|
|
guchar *src, *buf, *dest;
|
|
|
|
gint x, y;
|
|
|
|
gint pwidth, pheight;
|
|
|
|
GimpImage *gimage;
|
|
|
|
gdouble r, g, b, a, chk;
|
|
|
|
gint xoff = 0;
|
|
|
|
gint yoff = 0;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
gdisp = nav_dialog->gdisp;
|
|
|
|
gimage = gdisp->gimage;
|
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
gimp_set_busy (gimage->gimp);
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* Min size is 2 */
|
|
|
|
pwidth = nav_dialog->pwidth;
|
|
|
|
pheight = nav_dialog->pheight;
|
|
|
|
|
|
|
|
/* we need a large normal preview which we will cut down later.
|
|
|
|
* gimp_image_construct_composite_preview() can't cope with
|
|
|
|
* dot_for_dot not been set.
|
|
|
|
*/
|
|
|
|
if (! gdisp->dot_for_dot)
|
|
|
|
{
|
|
|
|
gint sel_width = gimage->width;
|
|
|
|
gint sel_height = gimage->height;
|
|
|
|
gdouble tratio;
|
|
|
|
|
|
|
|
if (sel_width > sel_height)
|
|
|
|
tratio = (gdouble) nav_dialog->nav_preview_width / ((gdouble) sel_width);
|
|
|
|
else
|
|
|
|
tratio = (gdouble) nav_dialog->nav_preview_height / ((gdouble) sel_height);
|
|
|
|
|
|
|
|
pwidth = sel_width * tratio + 0.5;
|
|
|
|
pheight = sel_height * tratio + 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nav_dialog->ratio > 1.0) /* Preview is scaling up! */
|
|
|
|
{
|
|
|
|
TempBuf *tmp;
|
|
|
|
|
|
|
|
tmp = gimp_viewable_get_new_preview (GIMP_VIEWABLE (gimage),
|
|
|
|
gimage->width,
|
|
|
|
gimage->height);
|
|
|
|
preview_buf = temp_buf_scale (tmp,
|
|
|
|
pwidth,
|
|
|
|
pheight);
|
|
|
|
temp_buf_free (tmp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
preview_buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (gimage),
|
|
|
|
MAX (pwidth, 2),
|
|
|
|
MAX (pheight, 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset & get new preview
|
|
|
|
*
|
|
|
|
* FIXME: should use gimp_preview_scale()
|
|
|
|
*/
|
|
|
|
if (! gdisp->dot_for_dot)
|
|
|
|
{
|
|
|
|
gint loop1, loop2;
|
|
|
|
gdouble x_ratio, y_ratio;
|
|
|
|
guchar *src_data;
|
|
|
|
guchar *dest_data;
|
|
|
|
|
|
|
|
preview_buf_notdot = temp_buf_new (nav_dialog->pwidth,
|
|
|
|
nav_dialog->pheight,
|
|
|
|
preview_buf->bytes,
|
|
|
|
0, 0, NULL);
|
|
|
|
|
|
|
|
x_ratio = (gdouble) pwidth / (gdouble) nav_dialog->pwidth;
|
|
|
|
y_ratio = (gdouble) pheight / (gdouble) nav_dialog->pheight;
|
|
|
|
|
|
|
|
src_data = temp_buf_data (preview_buf);
|
|
|
|
dest_data = temp_buf_data (preview_buf_notdot);
|
|
|
|
|
|
|
|
for (loop1 = 0 ; loop1 < nav_dialog->pheight ; loop1++)
|
|
|
|
for (loop2 = 0 ; loop2 < nav_dialog->pwidth ; loop2++)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
guchar *src_pixel;
|
|
|
|
guchar *dest_pixel;
|
|
|
|
|
|
|
|
src_pixel = src_data +
|
|
|
|
((gint) (loop2 * x_ratio)) * preview_buf->bytes +
|
|
|
|
((gint) (loop1 * y_ratio)) * pwidth * preview_buf->bytes;
|
|
|
|
|
|
|
|
dest_pixel = dest_data +
|
|
|
|
(loop2 + loop1 * nav_dialog->pwidth) * preview_buf->bytes;
|
|
|
|
|
|
|
|
for (i = 0 ; i < preview_buf->bytes; i++)
|
|
|
|
*dest_pixel++ = *src_pixel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pwidth = nav_dialog->pwidth;
|
|
|
|
pheight = nav_dialog->pheight;
|
|
|
|
|
|
|
|
src = temp_buf_data (preview_buf_notdot);
|
|
|
|
preview_buf_ptr = preview_buf_notdot;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
src = temp_buf_data (preview_buf);
|
|
|
|
preview_buf_ptr = preview_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = g_new (gchar, preview_buf_ptr->width * 3);
|
|
|
|
|
|
|
|
for (y = 0; y < preview_buf_ptr->height ; y++)
|
|
|
|
{
|
|
|
|
dest = buf;
|
1999-10-21 06:15:13 +08:00
|
|
|
switch (preview_buf_ptr->bytes)
|
1999-08-21 08:18:58 +08:00
|
|
|
{
|
|
|
|
case 4:
|
2000-04-25 20:32:10 +08:00
|
|
|
for (x = 0; x < preview_buf_ptr->width; x++)
|
1999-09-02 06:39:44 +08:00
|
|
|
{
|
2000-12-14 21:52:16 +08:00
|
|
|
r = ((gdouble) (*(src++))) / 255.0;
|
|
|
|
g = ((gdouble) (*(src++))) / 255.0;
|
|
|
|
b = ((gdouble) (*(src++))) / 255.0;
|
|
|
|
a = ((gdouble) (*(src++))) / 255.0;
|
|
|
|
chk = ((gdouble) ((( (x^y) & 4 ) << 4) | 128)) / 255.0;
|
|
|
|
*(dest++) = (guchar) ((chk + (r - chk) * a) * 255.0);
|
|
|
|
*(dest++) = (guchar) ((chk + (g - chk) * a) * 255.0);
|
|
|
|
*(dest++) = (guchar) ((chk + (b - chk) * a) * 255.0);
|
1999-09-02 06:39:44 +08:00
|
|
|
}
|
|
|
|
break;
|
2000-12-14 21:52:16 +08:00
|
|
|
|
1999-08-21 08:18:58 +08:00
|
|
|
case 2:
|
2000-04-25 20:32:10 +08:00
|
|
|
for (x = 0; x < preview_buf_ptr->width; x++)
|
1999-08-21 08:18:58 +08:00
|
|
|
{
|
2000-12-14 21:52:16 +08:00
|
|
|
r = ((gdouble) (*(src++))) / 255.0;
|
|
|
|
a = ((gdouble) (*(src++))) / 255.0;
|
|
|
|
chk = ((gdouble) ((( (x^y) & 4 ) << 4) | 128)) / 255.0;
|
|
|
|
*(dest++) = (guchar) ((chk + (r - chk) * a) * 255.0);
|
|
|
|
*(dest++) = (guchar) ((chk + (r - chk) * a) * 255.0);
|
|
|
|
*(dest++) = (guchar) ((chk + (r - chk) * a) * 255.0);
|
1999-08-21 08:18:58 +08:00
|
|
|
}
|
|
|
|
break;
|
2000-12-14 21:52:16 +08:00
|
|
|
|
1999-08-21 08:18:58 +08:00
|
|
|
default:
|
2001-06-18 21:10:03 +08:00
|
|
|
g_warning ("nav_dialog_update_preview(): UNKNOWN TempBuf bpp");
|
1999-08-21 08:18:58 +08:00
|
|
|
}
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (nav_dialog->preview),
|
|
|
|
buf,
|
2000-12-14 21:52:16 +08:00
|
|
|
xoff, yoff + y,
|
|
|
|
preview_buf_ptr->width);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (buf);
|
|
|
|
|
2000-12-15 23:54:17 +08:00
|
|
|
temp_buf_free (preview_buf);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2000-04-25 20:32:10 +08:00
|
|
|
if (preview_buf_notdot)
|
|
|
|
temp_buf_free (preview_buf_notdot);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
gimp_unset_busy (gimage->gimp);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
1999-09-02 06:39:44 +08:00
|
|
|
static void
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_update_preview_blank (NavigationDialog *nav_dialog)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
2000-12-14 21:52:16 +08:00
|
|
|
guchar *buf;
|
|
|
|
guchar *dest;
|
|
|
|
gint x, y;
|
|
|
|
gdouble chk;
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
buf = g_new (gchar, nav_dialog->pwidth * 3);
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
for (y = 0; y < nav_dialog->pheight ; y++)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
|
|
|
dest = buf;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
for (x = 0; x < nav_dialog->pwidth; x++)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
chk = ((gdouble) ((( (x^y) & 4 ) << 4) | 128)) / 255.0;
|
1999-08-28 03:07:21 +08:00
|
|
|
chk *= 128.0;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2000-12-14 21:52:16 +08:00
|
|
|
*(dest++) = (guchar) chk;
|
|
|
|
*(dest++) = (guchar) chk;
|
|
|
|
*(dest++) = (guchar) chk;
|
1999-08-28 03:07:21 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (nav_dialog->preview),
|
|
|
|
buf,
|
|
|
|
0, y, nav_dialog->pwidth);
|
1999-08-28 03:07:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (buf);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
1999-08-28 03:07:21 +08:00
|
|
|
static void
|
2001-06-18 21:10:03 +08:00
|
|
|
update_zoom_label (NavigationDialog *nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2000-12-14 21:52:16 +08:00
|
|
|
gchar scale_str[MAX_SCALE_BUF];
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog->zoom_label)
|
1999-09-02 06:39:44 +08:00
|
|
|
return;
|
|
|
|
|
1999-08-28 03:07:21 +08:00
|
|
|
/* Update the zoom scale string */
|
|
|
|
g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d",
|
2001-06-18 21:10:03 +08:00
|
|
|
SCALEDEST (nav_dialog->gdisp),
|
|
|
|
SCALESRC (nav_dialog->gdisp));
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (nav_dialog->zoom_label), scale_str);
|
1999-08-28 03:07:21 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
1999-08-28 03:07:21 +08:00
|
|
|
static void
|
2001-06-18 21:10:03 +08:00
|
|
|
update_zoom_adjustment (NavigationDialog *nav_dialog)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
1999-09-02 06:39:44 +08:00
|
|
|
GtkAdjustment *adj;
|
2001-06-18 21:10:03 +08:00
|
|
|
gdouble f;
|
|
|
|
gdouble val;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog->zoom_adjustment)
|
1999-09-02 06:39:44 +08:00
|
|
|
return;
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
adj = GTK_ADJUSTMENT (nav_dialog->zoom_adjustment);
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
f = (((gdouble) SCALEDEST (nav_dialog->gdisp)) /
|
|
|
|
((gdouble) SCALESRC (nav_dialog->gdisp)));
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2000-12-14 21:52:16 +08:00
|
|
|
if (f < 1.0)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
2000-12-14 21:52:16 +08:00
|
|
|
val = -1.0 / f;
|
1999-08-28 03:07:21 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val = f;
|
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (abs ((gint) adj->value) != (gint) (val - 1) &&
|
|
|
|
! nav_dialog->block_adj_sig)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
|
|
|
adj->value = val;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
gtk_adjustment_changed (GTK_ADJUSTMENT (nav_dialog->zoom_adjustment));
|
1999-08-28 03:07:21 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
1999-08-24 06:47:36 +08:00
|
|
|
static void
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_update_real_view (NavigationDialog *nav_dialog,
|
|
|
|
gint tx,
|
|
|
|
gint ty)
|
1999-08-24 06:47:36 +08:00
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble xratio;
|
|
|
|
gdouble yratio;
|
|
|
|
gint xoffset;
|
|
|
|
gint yoffset;
|
|
|
|
gint xpnt;
|
|
|
|
gint ypnt;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (nav_dialog->gdisp->shell);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
xratio = SCALEFACTOR_X (nav_dialog->gdisp);
|
|
|
|
yratio = SCALEFACTOR_Y (nav_dialog->gdisp);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
if ((tx + nav_dialog->dispwidth) >= nav_dialog->pwidth)
|
|
|
|
{
|
|
|
|
tx = nav_dialog->pwidth; /* Actually should be less...
|
|
|
|
* but bound check will save us.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
xpnt = (gint) (((gdouble) (tx) * xratio) / nav_dialog->ratio + 0.5);
|
|
|
|
|
|
|
|
if ((ty + nav_dialog->dispheight) >= nav_dialog->pheight)
|
1999-08-24 06:47:36 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
ty = nav_dialog->pheight; /* Same comment as for xpnt above. */
|
1999-08-24 06:47:36 +08:00
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
ypnt = (gint) (((gdouble) (ty) * yratio) / nav_dialog->ratio + 0.5);
|
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
if (! nav_dialog->gdisp->dot_for_dot) /* here */
|
|
|
|
xpnt = (((gdouble) xpnt *
|
|
|
|
nav_dialog->gdisp->gimage->xresolution) /
|
|
|
|
nav_dialog->gdisp->gimage->yresolution) + 0.5;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
xoffset = xpnt - shell->offset_x;
|
|
|
|
yoffset = ypnt - shell->offset_y;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scroll (shell, xoffset, yoffset);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
nav_dialog_move_to_point (NavigationDialog *nav_dialog,
|
|
|
|
gint tx,
|
|
|
|
gint ty)
|
|
|
|
{
|
|
|
|
tx = CLAMP (tx, 0, nav_dialog->pwidth);
|
|
|
|
ty = CLAMP (ty, 0, nav_dialog->pheight);
|
1999-08-24 06:47:36 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if ((tx + nav_dialog->dispwidth) >= nav_dialog->pwidth)
|
1999-08-24 06:47:36 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
tx = nav_dialog->pwidth - nav_dialog->dispwidth;
|
1999-08-24 06:47:36 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if ((ty + nav_dialog->dispheight) >= nav_dialog->pheight)
|
|
|
|
{
|
|
|
|
ty = nav_dialog->pheight - nav_dialog->dispheight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nav_dialog->dispx == tx && nav_dialog->dispy == ty)
|
1999-10-22 03:35:35 +08:00
|
|
|
return;
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_update_real_view (nav_dialog, tx, ty);
|
1999-08-24 06:47:36 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
1999-09-02 06:39:44 +08:00
|
|
|
static void
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_grab_pointer (NavigationDialog *nav_dialog,
|
|
|
|
GtkWidget *widget)
|
1999-09-02 06:39:44 +08:00
|
|
|
{
|
|
|
|
GdkCursor *cursor;
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->sq_grabbed = TRUE;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_grab_add (widget);
|
2000-12-15 23:54:17 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
cursor = gdk_cursor_new (GDK_CROSSHAIR);
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2000-12-15 23:54:17 +08:00
|
|
|
gdk_pointer_grab (widget->window, TRUE,
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK |
|
|
|
|
GDK_BUTTON_MOTION_MASK |
|
|
|
|
GDK_EXTENSION_EVENTS_ALL,
|
|
|
|
widget->window, cursor, 0);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2001-08-31 22:01:47 +08:00
|
|
|
gdk_cursor_unref (cursor);
|
1999-09-02 06:39:44 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static gboolean
|
|
|
|
nav_dialog_inside_preview_square (NavigationDialog *nav_dialog,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
|
|
|
{
|
2001-08-01 17:33:12 +08:00
|
|
|
return (x > nav_dialog->dispx &&
|
|
|
|
x < nav_dialog->dispx + nav_dialog->dispwidth &&
|
|
|
|
y > nav_dialog->dispy &&
|
|
|
|
y < nav_dialog->dispy + nav_dialog->dispheight);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
nav_dialog_preview_events (GtkWidget *widget,
|
1999-08-13 06:21:04 +08:00
|
|
|
GdkEvent *event,
|
2000-12-14 21:52:16 +08:00
|
|
|
gpointer data)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *nav_dialog;
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp;
|
2001-11-01 05:18:57 +08:00
|
|
|
GimpDisplayShell *shell;
|
2001-06-18 21:10:03 +08:00
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
|
|
|
GdkEventKey *kevent;
|
|
|
|
GdkModifierType mask;
|
|
|
|
gint tx = 0;
|
|
|
|
gint ty = 0;
|
|
|
|
gint mx;
|
|
|
|
gint my;
|
|
|
|
gboolean arrow_key = FALSE;
|
|
|
|
|
|
|
|
nav_dialog = (NavigationDialog *) data;
|
|
|
|
|
|
|
|
if (! nav_dialog || nav_dialog->frozen)
|
1999-08-13 06:21:04 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gdisp = nav_dialog->gdisp;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
|
|
|
|
1999-08-13 06:21:04 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
2001-08-01 17:33:12 +08:00
|
|
|
/* call default handler explicitly, then draw the square */
|
|
|
|
GTK_WIDGET_GET_CLASS (widget)->expose_event (widget,
|
|
|
|
(GdkEventExpose *) event);
|
|
|
|
nav_dialog_draw_sqr (nav_dialog, FALSE,
|
|
|
|
nav_dialog->dispx, nav_dialog->dispy,
|
|
|
|
nav_dialog->dispwidth, nav_dialog->dispheight);
|
|
|
|
return TRUE;
|
2000-12-14 21:52:16 +08:00
|
|
|
|
1999-08-13 06:21:04 +08:00
|
|
|
case GDK_MAP:
|
2001-06-18 21:10:03 +08:00
|
|
|
if (nav_dialog->ptype == NAV_POPUP)
|
1999-09-02 06:39:44 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_update_preview (nav_dialog);
|
|
|
|
|
1999-09-02 06:39:44 +08:00
|
|
|
/* First time displayed.... get the pointer! */
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_grab_pointer (nav_dialog, nav_dialog->preview);
|
1999-09-02 06:39:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_idle_update_preview (nav_dialog);
|
1999-09-02 06:39:44 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
tx = bevent->x;
|
|
|
|
ty = bevent->y;
|
|
|
|
|
|
|
|
/* Must start the move */
|
|
|
|
switch (bevent->button)
|
|
|
|
{
|
|
|
|
case 1:
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog_inside_preview_square (nav_dialog, tx, ty))
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
/* Direct scroll to the location
|
|
|
|
* view scrolled to the center or nearest possible point
|
|
|
|
*/
|
|
|
|
tx -= nav_dialog->dispwidth / 2;
|
|
|
|
ty -= nav_dialog->dispheight / 2;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_move_to_point (nav_dialog, tx, ty);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->motion_offsetx = nav_dialog->dispwidth / 2;
|
|
|
|
nav_dialog->motion_offsety = nav_dialog->dispheight / 2;
|
1999-09-02 06:39:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->motion_offsetx = tx - nav_dialog->dispx;
|
|
|
|
nav_dialog->motion_offsety = ty - nav_dialog->dispy;
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
|
|
|
|
nav_dialog_grab_pointer (nav_dialog, widget);
|
1999-10-16 21:07:15 +08:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* wheelmouse support */
|
|
|
|
case 4:
|
|
|
|
if (bevent->state & GDK_SHIFT_MASK)
|
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_IN);
|
1999-10-16 21:07:15 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj =
|
|
|
|
(bevent->state & GDK_CONTROL_MASK) ?
|
2001-11-01 05:18:57 +08:00
|
|
|
shell->hsbdata : shell->vsbdata;
|
1999-10-16 21:07:15 +08:00
|
|
|
gfloat new_value = adj->value - adj->page_increment / 2;
|
|
|
|
new_value =
|
|
|
|
CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
|
|
|
break;
|
1999-09-05 06:27:20 +08:00
|
|
|
|
1999-10-16 21:07:15 +08:00
|
|
|
case 5:
|
|
|
|
if (bevent->state & GDK_SHIFT_MASK)
|
|
|
|
{
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT);
|
1999-10-16 21:07:15 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj =
|
|
|
|
(bevent->state & GDK_CONTROL_MASK) ?
|
2001-11-01 05:18:57 +08:00
|
|
|
shell->hsbdata : shell->vsbdata;
|
1999-10-16 21:07:15 +08:00
|
|
|
gfloat new_value = adj->value + adj->page_increment / 2;
|
|
|
|
new_value = CLAMP (new_value,
|
|
|
|
adj->lower, adj->upper - adj->page_size);
|
|
|
|
gtk_adjustment_set_value (adj, new_value);
|
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
break;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
tx = bevent->x;
|
|
|
|
ty = bevent->y;
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
switch (bevent->button)
|
1999-11-20 08:46:58 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
case 1:
|
|
|
|
nav_dialog->sq_grabbed = FALSE;
|
|
|
|
gtk_grab_remove (widget);
|
|
|
|
gdk_pointer_ungrab (0);
|
|
|
|
if (nav_dialog->ptype == NAV_POPUP)
|
|
|
|
{
|
|
|
|
gtk_widget_hide (nav_dialog->shell);
|
|
|
|
}
|
|
|
|
gdk_flush ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1999-11-20 08:46:58 +08:00
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
break;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
case GDK_KEY_PRESS:
|
|
|
|
/* hack for the update preview... needs to be fixed */
|
|
|
|
kevent = (GdkEventKey *) event;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
case GDK_space:
|
|
|
|
gdk_window_raise (gdisp->shell->window);
|
|
|
|
break;
|
|
|
|
case GDK_Up:
|
|
|
|
arrow_key = TRUE;
|
|
|
|
tx = nav_dialog->dispx;
|
|
|
|
ty = nav_dialog->dispy - 1;
|
|
|
|
break;
|
|
|
|
case GDK_Left:
|
|
|
|
arrow_key = TRUE;
|
|
|
|
tx = nav_dialog->dispx - 1;
|
|
|
|
ty = nav_dialog->dispy;
|
|
|
|
break;
|
|
|
|
case GDK_Right:
|
|
|
|
arrow_key = TRUE;
|
|
|
|
tx = nav_dialog->dispx + 1;
|
|
|
|
ty = nav_dialog->dispy;
|
|
|
|
break;
|
|
|
|
case GDK_Down:
|
|
|
|
arrow_key = TRUE;
|
|
|
|
tx = nav_dialog->dispx;
|
|
|
|
ty = nav_dialog->dispy + 1;
|
|
|
|
break;
|
|
|
|
case GDK_equal:
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_IN);
|
2001-06-18 21:10:03 +08:00
|
|
|
break;
|
|
|
|
case GDK_minus:
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scale (shell, GIMP_ZOOM_OUT);
|
2001-06-18 21:10:03 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (arrow_key)
|
|
|
|
{
|
|
|
|
nav_dialog_move_to_point (nav_dialog, tx, ty);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
mevent = (GdkEventMotion *) event;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog->sq_grabbed)
|
|
|
|
break;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gdk_window_get_pointer (widget->window, &mx, &my, &mask);
|
|
|
|
tx = mx;
|
|
|
|
ty = my;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
tx = tx - nav_dialog->motion_offsetx;
|
|
|
|
ty = ty - nav_dialog->motion_offsety;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_move_to_point (nav_dialog, tx, ty);
|
|
|
|
break;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
1999-11-20 08:46:58 +08:00
|
|
|
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void
|
|
|
|
nav_image_need_update (GimpImage *gimage,
|
|
|
|
gpointer data)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *nav_dialog;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog = (NavigationDialog *) data;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog ||
|
|
|
|
! GTK_WIDGET_VISIBLE (nav_dialog->shell) ||
|
|
|
|
nav_dialog->frozen)
|
1999-08-13 06:21:04 +08:00
|
|
|
return;
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_idle_update_preview (nav_dialog);
|
1999-08-28 03:07:21 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void
|
|
|
|
navwindow_zoomin (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *nav_dialog;
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog = (NavigationDialog *) data;
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if(! nav_dialog || nav_dialog->frozen)
|
|
|
|
return;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (nav_dialog->gdisp->shell),
|
|
|
|
GIMP_ZOOM_IN);
|
1999-11-20 08:46:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-18 21:10:03 +08:00
|
|
|
navwindow_zoomout (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-11-20 08:46:58 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *nav_dialog;
|
|
|
|
|
|
|
|
nav_dialog = (NavigationDialog *)data;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog || nav_dialog->frozen)
|
|
|
|
return;
|
|
|
|
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (nav_dialog->gdisp->shell),
|
|
|
|
GIMP_ZOOM_OUT);
|
1999-11-20 08:46:58 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void
|
|
|
|
zoom_adj_changed (GtkAdjustment *adj,
|
|
|
|
gpointer data)
|
1999-11-20 08:46:58 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
NavigationDialog *nav_dialog;
|
|
|
|
gint scalesrc;
|
|
|
|
gint scaledest;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog = (NavigationDialog *)data;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog || nav_dialog->frozen)
|
|
|
|
return;
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (adj->value < 0.0)
|
1999-11-20 08:46:58 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
scalesrc = abs ((gint) adj->value - 1);
|
|
|
|
scaledest = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scaledest = abs ((gint) adj->value + 1);
|
|
|
|
scalesrc = 1;
|
1999-11-20 08:46:58 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->block_adj_sig = TRUE;
|
2001-11-01 05:18:57 +08:00
|
|
|
gimp_display_shell_scale (GIMP_DISPLAY_SHELL (nav_dialog->gdisp),
|
|
|
|
(scaledest * 100) + scalesrc);
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->block_adj_sig = FALSE;
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static GtkWidget *
|
|
|
|
nav_create_button_area (NavigationDialog *nav_dialog)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
2002-01-03 01:20:50 +08:00
|
|
|
GtkWidget *image;
|
2001-06-18 21:10:03 +08:00
|
|
|
GtkWidget *hscale;
|
|
|
|
gchar scale_str[MAX_SCALE_BUF];
|
1999-11-21 06:33:46 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2002-01-03 01:20:50 +08:00
|
|
|
button = gtk_button_new ();
|
2001-06-18 21:10:03 +08:00
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2002-01-03 01:20:50 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (navwindow_zoomout),
|
|
|
|
nav_dialog);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* user zoom ratio */
|
|
|
|
g_snprintf (scale_str, MAX_SCALE_BUF, "%d:%d",
|
|
|
|
SCALEDEST (nav_dialog->gdisp),
|
|
|
|
SCALESRC (nav_dialog->gdisp));
|
|
|
|
|
|
|
|
nav_dialog->zoom_label = gtk_label_new (scale_str);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), nav_dialog->zoom_label, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (nav_dialog->zoom_label);
|
1999-11-21 06:33:46 +08:00
|
|
|
|
2002-01-03 01:20:50 +08:00
|
|
|
button = gtk_button_new ();
|
2001-06-18 21:10:03 +08:00
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
1999-11-21 06:33:46 +08:00
|
|
|
|
2002-01-03 01:20:50 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (navwindow_zoomin),
|
|
|
|
nav_dialog);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->zoom_adjustment =
|
|
|
|
gtk_adjustment_new (0.0, -15.0, 16.0, 1.0, 1.0, 1.0);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (nav_dialog->zoom_adjustment), "value_changed",
|
|
|
|
G_CALLBACK (zoom_adj_changed),
|
|
|
|
nav_dialog);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
hscale = gtk_hscale_new (GTK_ADJUSTMENT (nav_dialog->zoom_adjustment));
|
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (hscale), FALSE);
|
|
|
|
gtk_scale_set_digits (GTK_SCALE (hscale), 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hscale, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (hscale);
|
1999-11-21 06:33:46 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
return vbox;
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void
|
|
|
|
nav_dialog_display_changed (GimpContext *context,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp,
|
2001-06-18 21:10:03 +08:00
|
|
|
gpointer data)
|
1999-09-02 06:39:44 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *old_gdisp;
|
2001-06-18 21:10:03 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
NavigationDialog *nav_dialog;
|
|
|
|
gchar *title;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog = (NavigationDialog *) data;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
old_gdisp = nav_dialog->gdisp;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (! nav_dialog || gdisp == old_gdisp || ! gdisp)
|
|
|
|
return;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_widget_set_sensitive (nav_window_auto->shell, TRUE);
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog->frozen = FALSE;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
title = nav_dialog_title (gdisp);
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW (nav_dialog->shell), title);
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
g_free (title);
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gimage = gdisp->gimage;
|
2000-02-19 21:19:08 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
if (gimage && gimp_container_have (context->gimp->images,
|
|
|
|
GIMP_OBJECT (gimage)))
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
|
|
|
nav_dialog->gdisp = gdisp;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* Update preview to new display */
|
|
|
|
nav_dialog_preview_resized (nav_dialog);
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (nav_dialog->new_preview)
|
|
|
|
gimp_preview_set_viewable (GIMP_PREVIEW (nav_dialog->new_preview),
|
|
|
|
GIMP_VIEWABLE (gdisp->gimage));
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
/* Tie into the dirty signal so we can update the preview
|
|
|
|
* provided we haven't already
|
|
|
|
*/
|
2001-07-25 08:27:41 +08:00
|
|
|
if (! g_object_get_data (G_OBJECT (gimage), "nav_handlers_installed"))
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2001-08-01 17:33:12 +08:00
|
|
|
g_signal_connect (G_OBJECT (gimage), "dirty",
|
|
|
|
G_CALLBACK (nav_image_need_update),
|
|
|
|
nav_dialog);
|
|
|
|
g_signal_connect (G_OBJECT (gimage), "clean",
|
|
|
|
G_CALLBACK (nav_image_need_update),
|
|
|
|
nav_dialog);
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2001-07-25 08:27:41 +08:00
|
|
|
g_object_set_data (G_OBJECT (gimage),
|
|
|
|
"nav_handlers_installed",
|
|
|
|
nav_dialog);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
}
|
1999-09-02 06:39:44 +08:00
|
|
|
}
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
static GimpDisplay *
|
2001-06-18 21:10:03 +08:00
|
|
|
nav_dialog_get_gdisp (void)
|
1999-09-05 06:27:20 +08:00
|
|
|
{
|
2001-06-18 21:10:03 +08:00
|
|
|
GList *list;
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
for (list = GIMP_LIST (the_gimp->images)->list;
|
2001-06-18 21:10:03 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpDisplay *gdisp;
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gimage = GIMP_IMAGE (list->data);
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
gdisp = gdisplays_check_valid (NULL, gimage);
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (gdisp)
|
|
|
|
return gdisp;
|
|
|
|
}
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
return NULL;
|
1999-09-05 06:27:20 +08:00
|
|
|
}
|