app/display/gimpnavigationview.c renamed these files to...

* app/display/gimpnavigationview.c
* app/display/gimpnavigationview.h: renamed these files to...

* app/display/gimpnavigationeditor.c
* app/display/gimpnavigationeditor.h: ... these files, and of course
  changed GimpNavigationView to GimpNavigationEditor since it is really
  inherited from GimpEditor anyway.

This will leave the gimp_navigation_view namespace for the renaming
from gimp_navigation_preview.

* app/display/Makefile.am
* app/display/display-types.h
* app/display/gimpdisplayshell-callbacks.c
* app/gui/dialogs-constructors.c: Changed accordlingly.
This commit is contained in:
David Odin 2004-08-25 16:02:10 +00:00
parent da34232a04
commit f168881c18
10 changed files with 325 additions and 1149 deletions

View File

@ -1,3 +1,21 @@
2004-08-25 DindinX <david@dindinx.org>
* app/display/gimpnavigationview.c
* app/display/gimpnavigationview.h: renamed these files to...
* app/display/gimpnavigationeditor.c
* app/display/gimpnavigationeditor.h: ... these files, and of course
changed GimpNavigationView to GimpNavigationEditor since it is really
inherited from GimpEditor anyway.
This will leave the gimp_navigation_view namespace for the renaming
from gimp_navigation_preview.
* app/display/Makefile.am
* app/display/display-types.h
* app/display/gimpdisplayshell-callbacks.c
* app/gui/dialogs-constructors.c: Changed accordlingly.
2004-08-25 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell-title.c

View File

@ -68,7 +68,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpnavigationview.h"
#include "display/gimpnavigationeditor.h"
#include "actions/channels-commands.h"
#include "actions/edit-commands.h"
@ -829,8 +829,8 @@ dialogs_navigation_view_new (GimpDialogFactory *factory,
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
view = gimp_navigation_view_new (shell,
GIMP_DISPLAY_CONFIG (context->gimp->config));
view = gimp_navigation_editor_new (shell,
GIMP_DISPLAY_CONFIG (context->gimp->config));
return dialogs_dockable_new (view,
_("Navigation"), _("Display Navigation"),

View File

@ -62,8 +62,8 @@ libappdisplay_a_sources = \
gimpdisplayshell-title.h \
gimpdisplayshell-transform.c \
gimpdisplayshell-transform.h \
gimpnavigationview.c \
gimpnavigationview.h \
gimpnavigationeditor.c \
gimpnavigationeditor.h \
gimpscalecombobox.c \
gimpscalecombobox.h \
gimpstatusbar.c \

View File

@ -31,7 +31,7 @@ typedef struct _GimpDisplay GimpDisplay;
typedef struct _GimpDisplayShell GimpDisplayShell;
/* typedef struct _GimpDisplayOptions GimpDisplayOptions; in config-types.h */
typedef struct _GimpNavigationView GimpNavigationView;
typedef struct _GimpNavigationEditor GimpNavigationEditor;
typedef struct _GimpScaleComboBox GimpScaleComboBox;
typedef struct _GimpStatusbar GimpStatusbar;

View File

@ -71,7 +71,7 @@
#include "gimpdisplayshell-selection.h"
#include "gimpdisplayshell-title.h"
#include "gimpdisplayshell-transform.h"
#include "gimpnavigationview.h"
#include "gimpnavigationeditor.h"
#include "gimp-intl.h"
@ -1555,7 +1555,7 @@ gimp_display_shell_nav_button_press (GtkWidget *widget,
{
if ((bevent->type == GDK_BUTTON_PRESS) && (bevent->button == 1))
{
gimp_navigation_view_popup (shell, widget, bevent->x, bevent->y);
gimp_navigation_editor_popup (shell, widget, bevent->x, bevent->y);
}
return TRUE;

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpnavigationview.c
* gimpnavigationeditor.c
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
*
* partly based on app/nav_window
@ -45,7 +45,7 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpnavigationview.h"
#include "gimpnavigationeditor.h"
#include "gimp-intl.h"
@ -53,90 +53,89 @@
#define MAX_SCALE_BUF 20
static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass);
static void gimp_navigation_view_init (GimpNavigationView *view);
static void gimp_navigation_editor_class_init (GimpNavigationEditorClass *klass);
static void gimp_navigation_editor_init (GimpNavigationEditor *editor);
static void gimp_navigation_view_docked_iface_init (GimpDockedInterface *docked_iface);
static void gimp_navigation_view_set_context (GimpDocked *docked,
GimpContext *context);
static void gimp_navigation_editor_docked_iface_init (GimpDockedInterface *docked_iface);
static void gimp_navigation_editor_set_context (GimpDocked *docked,
GimpContext *context);
static void gimp_navigation_view_destroy (GtkObject *object);
static void gimp_navigation_editor_destroy (GtkObject *object);
static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
GimpDisplayConfig *config,
gboolean popup);
static GtkWidget * gimp_navigation_editor_new_private (GimpDisplayShell *shell,
GimpDisplayConfig *config,
gboolean popup);
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gdouble x,
gdouble y,
GimpNavigationView *view);
static void gimp_navigation_view_zoom (GimpNavigationPreview *preview,
GimpZoomType direction,
GimpNavigationView *view);
static void gimp_navigation_view_scroll (GimpNavigationPreview *preview,
GdkScrollDirection direction,
GimpNavigationView *view);
static gboolean gimp_navigation_editor_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
static void gimp_navigation_editor_marker_changed (GimpNavigationPreview *preview,
gdouble x,
gdouble y,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_zoom (GimpNavigationPreview *preview,
GimpZoomType direction,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_scroll (GimpNavigationPreview *preview,
GdkScrollDirection direction,
GimpNavigationEditor *editor);
static void gimp_navigation_view_zoom_adj_changed (GtkAdjustment *adj,
GimpNavigationView *view);
static void gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
GimpNavigationEditor *editor);
static void gimp_navigation_view_zoom_out_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_in_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_100_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_fit_in_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_fit_to_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_shrink_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_editor_zoom_out_clicked (GtkWidget *widget,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_zoom_in_clicked (GtkWidget *widget,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_zoom_100_clicked (GtkWidget *widget,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_zoom_fit_in_clicked (GtkWidget *widget,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_zoom_fit_to_clicked (GtkWidget *widget,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_shrink_clicked (GtkWidget *widget,
GimpNavigationEditor *editor);
static void gimp_navigation_view_shell_scaled (GimpDisplayShell *shell,
GimpNavigationView *view);
static void gimp_navigation_view_shell_scrolled (GimpDisplayShell *shell,
GimpNavigationView *view);
static void gimp_navigation_view_shell_reconnect (GimpDisplayShell *shell,
GimpNavigationView *view);
static void gimp_navigation_view_update_marker (GimpNavigationView *view);
static void gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
GimpNavigationEditor *editor);
static void gimp_navigation_editor_update_marker (GimpNavigationEditor *editor);
static GimpEditorClass *parent_class = NULL;
GType
gimp_navigation_view_get_type (void)
gimp_navigation_editor_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo view_info =
static const GTypeInfo editor_info =
{
sizeof (GimpNavigationViewClass),
sizeof (GimpNavigationEditorClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_navigation_view_class_init,
(GClassInitFunc) gimp_navigation_editor_class_init,
NULL, /* class_finalize */
NULL, /* class_navigation */
sizeof (GimpNavigationView),
sizeof (GimpNavigationEditor),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_navigation_view_init,
(GInstanceInitFunc) gimp_navigation_editor_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_navigation_view_docked_iface_init,
(GInterfaceInitFunc) gimp_navigation_editor_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
"GimpNavigationEditor",
&editor_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
@ -146,7 +145,7 @@ gimp_navigation_view_get_type (void)
}
static void
gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
gimp_navigation_editor_class_init (GimpNavigationEditorClass *klass)
{
GObjectClass *object_class;
GtkObjectClass *gtk_object_class;
@ -156,81 +155,81 @@ gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
parent_class = g_type_class_peek_parent (klass);
gtk_object_class->destroy = gimp_navigation_view_destroy;
gtk_object_class->destroy = gimp_navigation_editor_destroy;
}
static void
gimp_navigation_view_init (GimpNavigationView *view)
gimp_navigation_editor_init (GimpNavigationEditor *editor)
{
GtkWidget *frame;
view->shell = NULL;
editor->shell = NULL;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (view), frame, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
view->preview = gimp_view_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
GIMP_TYPE_IMAGE,
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
gtk_container_add (GTK_CONTAINER (frame), view->preview);
gtk_widget_show (view->preview);
editor->preview = gimp_view_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
GIMP_TYPE_IMAGE,
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
gtk_container_add (GTK_CONTAINER (frame), editor->preview);
gtk_widget_show (editor->preview);
g_signal_connect (view->preview, "marker_changed",
G_CALLBACK (gimp_navigation_view_marker_changed),
view);
g_signal_connect (view->preview, "zoom",
G_CALLBACK (gimp_navigation_view_zoom),
view);
g_signal_connect (view->preview, "scroll",
G_CALLBACK (gimp_navigation_view_scroll),
view);
g_signal_connect (editor->preview, "marker_changed",
G_CALLBACK (gimp_navigation_editor_marker_changed),
editor);
g_signal_connect (editor->preview, "zoom",
G_CALLBACK (gimp_navigation_editor_zoom),
editor);
g_signal_connect (editor->preview, "scroll",
G_CALLBACK (gimp_navigation_editor_scroll),
editor);
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
static void
gimp_navigation_view_docked_iface_init (GimpDockedInterface *docked_iface)
gimp_navigation_editor_docked_iface_init (GimpDockedInterface *docked_iface)
{
docked_iface->set_context = gimp_navigation_view_set_context;
docked_iface->set_context = gimp_navigation_editor_set_context;
}
static void
gimp_navigation_view_context_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
gimp_navigation_editor_context_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationEditor *editor)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
gimp_navigation_editor_set_shell (editor, shell);
}
static void
gimp_navigation_view_set_context (GimpDocked *docked,
GimpContext *context)
gimp_navigation_editor_set_context (GimpDocked *docked,
GimpContext *context)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (docked);
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
GimpNavigationEditor *editor = GIMP_NAVIGATION_EDITOR (docked);
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
if (view->context)
if (editor->context)
{
g_signal_handlers_disconnect_by_func (view->context,
gimp_navigation_view_context_changed,
view);
g_signal_handlers_disconnect_by_func (editor->context,
gimp_navigation_editor_context_changed,
editor);
}
view->context = context;
editor->context = context;
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (gimp_navigation_view_context_changed),
view);
G_CALLBACK (gimp_navigation_editor_context_changed),
editor);
gdisp = gimp_context_get_display (context);
}
@ -238,16 +237,16 @@ gimp_navigation_view_set_context (GimpDocked *docked,
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
gimp_navigation_editor_set_shell (editor, shell);
}
static void
gimp_navigation_view_destroy (GtkObject *object)
gimp_navigation_editor_destroy (GtkObject *object)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (object);
GimpNavigationEditor *editor = GIMP_NAVIGATION_EDITOR (object);
if (view->shell)
gimp_navigation_view_set_shell (view, NULL);
if (editor->shell)
gimp_navigation_editor_set_shell (editor, NULL);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -256,72 +255,72 @@ gimp_navigation_view_destroy (GtkObject *object)
/* public functions */
GtkWidget *
gimp_navigation_view_new (GimpDisplayShell *shell,
GimpDisplayConfig *config)
gimp_navigation_editor_new (GimpDisplayShell *shell,
GimpDisplayConfig *config)
{
return gimp_navigation_view_new_private (shell, config, FALSE);
return gimp_navigation_editor_new_private (shell, config, FALSE);
}
void
gimp_navigation_view_set_shell (GimpNavigationView *view,
GimpDisplayShell *shell)
gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (view));
g_return_if_fail (GIMP_IS_NAVIGATION_EDITOR (editor));
g_return_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell));
if (shell == view->shell)
if (shell == editor->shell)
return;
if (view->shell)
if (editor->shell)
{
g_signal_handlers_disconnect_by_func (view->shell,
gimp_navigation_view_shell_scaled,
view);
g_signal_handlers_disconnect_by_func (view->shell,
gimp_navigation_view_shell_scrolled,
view);
g_signal_handlers_disconnect_by_func (view->shell,
gimp_navigation_view_shell_reconnect,
view);
g_signal_handlers_disconnect_by_func (editor->shell,
gimp_navigation_editor_shell_scaled,
editor);
g_signal_handlers_disconnect_by_func (editor->shell,
gimp_navigation_editor_shell_scrolled,
editor);
g_signal_handlers_disconnect_by_func (editor->shell,
gimp_navigation_editor_shell_reconnect,
editor);
}
else if (shell)
{
gtk_widget_set_sensitive (GTK_WIDGET (view), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
}
view->shell = shell;
editor->shell = shell;
if (view->shell)
if (editor->shell)
{
gimp_view_set_viewable (GIMP_VIEW (view->preview),
gimp_view_set_viewable (GIMP_VIEW (editor->preview),
GIMP_VIEWABLE (shell->gdisp->gimage));
g_signal_connect (view->shell, "scaled",
G_CALLBACK (gimp_navigation_view_shell_scaled),
view);
g_signal_connect (view->shell, "scrolled",
G_CALLBACK (gimp_navigation_view_shell_scrolled),
view);
g_signal_connect (view->shell, "reconnect",
G_CALLBACK (gimp_navigation_view_shell_reconnect),
view);
g_signal_connect (editor->shell, "scaled",
G_CALLBACK (gimp_navigation_editor_shell_scaled),
editor);
g_signal_connect (editor->shell, "scrolled",
G_CALLBACK (gimp_navigation_editor_shell_scrolled),
editor);
g_signal_connect (editor->shell, "reconnect",
G_CALLBACK (gimp_navigation_editor_shell_reconnect),
editor);
gimp_navigation_view_shell_scaled (view->shell, view);
gimp_navigation_editor_shell_scaled (editor->shell, editor);
}
else
{
gimp_view_set_viewable (GIMP_VIEW (view->preview), NULL);
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
gimp_view_set_viewable (GIMP_VIEW (editor->preview), NULL);
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
}
void
gimp_navigation_view_popup (GimpDisplayShell *shell,
GtkWidget *widget,
gint click_x,
gint click_y)
gimp_navigation_editor_popup (GimpDisplayShell *shell,
GtkWidget *widget,
gint click_x,
gint click_y)
{
GimpNavigationView *view;
GimpNavigationEditor *editor;
GimpNavigationPreview *preview;
GdkScreen *screen;
gint x, y;
@ -344,26 +343,27 @@ gimp_navigation_view_popup (GimpDisplayShell *shell,
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
view = GIMP_NAVIGATION_VIEW (gimp_navigation_view_new_private (shell,
config,
TRUE));
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view));
gtk_widget_show (GTK_WIDGET (view));
editor =
GIMP_NAVIGATION_EDITOR (gimp_navigation_editor_new_private (shell,
config,
TRUE));
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (editor));
gtk_widget_show (GTK_WIDGET (editor));
g_signal_connect (view->preview, "button_release_event",
G_CALLBACK (gimp_navigation_view_button_release),
g_signal_connect (editor->preview, "button_release_event",
G_CALLBACK (gimp_navigation_editor_button_release),
shell);
}
else
{
view = GIMP_NAVIGATION_VIEW (GTK_BIN (GTK_BIN (shell->nav_popup)->child)->child);
editor = GIMP_NAVIGATION_EDITOR (GTK_BIN (GTK_BIN (shell->nav_popup)->child)->child);
}
screen = gtk_widget_get_screen (widget);
gtk_window_set_screen (GTK_WINDOW (shell->nav_popup), screen);
preview = GIMP_NAVIGATION_PREVIEW (view->preview);
preview = GIMP_NAVIGATION_PREVIEW (editor->preview);
/* decide where to put the popup */
gdk_window_get_origin (widget->window, &x_org, &y_org);
@ -415,21 +415,21 @@ gimp_navigation_view_popup (GimpDisplayShell *shell,
/* private functions */
static GtkWidget *
gimp_navigation_view_new_private (GimpDisplayShell *shell,
GimpDisplayConfig *config,
gboolean popup)
gimp_navigation_editor_new_private (GimpDisplayShell *shell,
GimpDisplayConfig *config,
gboolean popup)
{
GimpNavigationView *view;
GimpNavigationEditor *editor;
g_return_val_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell), NULL);
g_return_val_if_fail (GIMP_IS_DISPLAY_CONFIG (config), NULL);
g_return_val_if_fail (! popup || (popup && shell), NULL);
view = g_object_new (GIMP_TYPE_NAVIGATION_VIEW, NULL);
editor = g_object_new (GIMP_TYPE_NAVIGATION_EDITOR, NULL);
if (popup)
{
GimpView *preview = GIMP_VIEW (view->preview);
GimpView *preview = GIMP_VIEW (editor->preview);
gimp_preview_renderer_set_size (preview->renderer,
config->nav_preview_size * 3,
@ -439,107 +439,107 @@ gimp_navigation_view_new_private (GimpDisplayShell *shell,
{
GtkWidget *hscale;
gtk_widget_set_size_request (view->preview,
gtk_widget_set_size_request (editor->preview,
GIMP_PREVIEW_SIZE_HUGE,
GIMP_PREVIEW_SIZE_HUGE);
gimp_view_set_expand (GIMP_VIEW (view->preview), TRUE);
gimp_view_set_expand (GIMP_VIEW (editor->preview), TRUE);
/* the editor buttons */
view->zoom_out_button =
gimp_editor_add_button (GIMP_EDITOR (view),
editor->zoom_out_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ZOOM_OUT, _("Zoom out"),
GIMP_HELP_VIEW_ZOOM_OUT,
G_CALLBACK (gimp_navigation_view_zoom_out_clicked),
G_CALLBACK (gimp_navigation_editor_zoom_out_clicked),
NULL,
view);
editor);
view->zoom_in_button =
gimp_editor_add_button (GIMP_EDITOR (view),
editor->zoom_in_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ZOOM_IN, _("Zoom in"),
GIMP_HELP_VIEW_ZOOM_IN,
G_CALLBACK (gimp_navigation_view_zoom_in_clicked),
G_CALLBACK (gimp_navigation_editor_zoom_in_clicked),
NULL,
view);
editor);
view->zoom_100_button =
gimp_editor_add_button (GIMP_EDITOR (view),
editor->zoom_100_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ZOOM_100, _("Zoom 1:1"),
GIMP_HELP_VIEW_ZOOM_100,
G_CALLBACK (gimp_navigation_view_zoom_100_clicked),
G_CALLBACK (gimp_navigation_editor_zoom_100_clicked),
NULL,
view);
editor);
view->zoom_fit_in_button =
gimp_editor_add_button (GIMP_EDITOR (view),
editor->zoom_fit_in_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ZOOM_FIT, _("Fit Image in Window"),
GIMP_HELP_VIEW_ZOOM_FIT_IN,
G_CALLBACK (gimp_navigation_view_zoom_fit_in_clicked),
G_CALLBACK (gimp_navigation_editor_zoom_fit_in_clicked),
NULL,
view);
editor);
view->zoom_fit_to_button =
gimp_editor_add_button (GIMP_EDITOR (view),
editor->zoom_fit_to_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ZOOM_FIT, _("Fit Image to Window"),
GIMP_HELP_VIEW_ZOOM_FIT_TO,
G_CALLBACK (gimp_navigation_view_zoom_fit_to_clicked),
G_CALLBACK (gimp_navigation_editor_zoom_fit_to_clicked),
NULL,
view);
editor);
view->shrink_wrap_button =
gimp_editor_add_button (GIMP_EDITOR (view),
editor->shrink_wrap_button =
gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ZOOM_FIT, _("Shrink Wrap"),
GIMP_HELP_VIEW_SHRINK_WRAP,
G_CALLBACK (gimp_navigation_view_shrink_clicked),
G_CALLBACK (gimp_navigation_editor_shrink_clicked),
NULL,
view);
editor);
/* the zoom scale */
view->zoom_adjustment =
editor->zoom_adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -8.0, 8.0, 0.5, 1.0, 0.0));
g_signal_connect (view->zoom_adjustment, "value_changed",
G_CALLBACK (gimp_navigation_view_zoom_adj_changed),
view);
g_signal_connect (editor->zoom_adjustment, "value_changed",
G_CALLBACK (gimp_navigation_editor_zoom_adj_changed),
editor);
hscale = gtk_hscale_new (GTK_ADJUSTMENT (view->zoom_adjustment));
hscale = gtk_hscale_new (GTK_ADJUSTMENT (editor->zoom_adjustment));
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_DELAYED);
gtk_scale_set_draw_value (GTK_SCALE (hscale), FALSE);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_box_pack_end (GTK_BOX (view), hscale, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (editor), hscale, FALSE, FALSE, 0);
gtk_widget_show (hscale);
/* the zoom label */
view->zoom_label = gtk_label_new ("100%");
gtk_box_pack_end (GTK_BOX (view), view->zoom_label, FALSE, FALSE, 0);
gtk_widget_show (view->zoom_label);
editor->zoom_label = gtk_label_new ("100%");
gtk_box_pack_end (GTK_BOX (editor), editor->zoom_label, FALSE, FALSE, 0);
gtk_widget_show (editor->zoom_label);
/* eek */
{
GtkRequisition requisition;
gtk_widget_size_request (view->zoom_label, &requisition);
gtk_widget_set_size_request (view->zoom_label,
gtk_widget_size_request (editor->zoom_label, &requisition);
gtk_widget_set_size_request (editor->zoom_label,
4 * requisition.width,
requisition.height);
}
}
if (shell)
gimp_navigation_view_set_shell (view, shell);
gimp_navigation_editor_set_shell (editor, shell);
gimp_preview_renderer_set_background (GIMP_VIEW (view->preview)->renderer,
gimp_preview_renderer_set_background (GIMP_VIEW (editor->preview)->renderer,
GIMP_STOCK_TEXTURE);
return GTK_WIDGET (view);
return GTK_WIDGET (editor);
}
static gboolean
gimp_navigation_view_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell)
gimp_navigation_editor_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell)
{
if (bevent->button == 1)
{
@ -550,47 +550,47 @@ gimp_navigation_view_button_release (GtkWidget *widget,
}
static void
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gdouble x,
gdouble y,
GimpNavigationView *view)
gimp_navigation_editor_marker_changed (GimpNavigationPreview *preview,
gdouble x,
gdouble y,
GimpNavigationEditor *editor)
{
if (view->shell)
if (editor->shell)
{
gdouble xratio;
gdouble yratio;
gint xoffset;
gint yoffset;
xratio = SCALEFACTOR_X (view->shell);
yratio = SCALEFACTOR_Y (view->shell);
xratio = SCALEFACTOR_X (editor->shell);
yratio = SCALEFACTOR_Y (editor->shell);
xoffset = RINT (x * xratio - view->shell->offset_x);
yoffset = RINT (y * yratio - view->shell->offset_y);
xoffset = RINT (x * xratio - editor->shell->offset_x);
yoffset = RINT (y * yratio - editor->shell->offset_y);
gimp_display_shell_scroll (view->shell, xoffset, yoffset);
gimp_display_shell_scroll (editor->shell, xoffset, yoffset);
}
}
static void
gimp_navigation_view_zoom (GimpNavigationPreview *preview,
GimpZoomType direction,
GimpNavigationView *view)
gimp_navigation_editor_zoom (GimpNavigationPreview *preview,
GimpZoomType direction,
GimpNavigationEditor *editor)
{
g_return_if_fail (direction != GIMP_ZOOM_TO);
if (view->shell)
if (editor->shell)
{
gimp_display_shell_scale (view->shell, direction, 0.0);
gimp_display_shell_scale (editor->shell, direction, 0.0);
}
}
static void
gimp_navigation_view_scroll (GimpNavigationPreview *preview,
GdkScrollDirection direction,
GimpNavigationView *view)
gimp_navigation_editor_scroll (GimpNavigationPreview *preview,
GdkScrollDirection direction,
GimpNavigationEditor *editor)
{
if (view->shell)
if (editor->shell)
{
GtkAdjustment *adj = NULL;
gdouble value;
@ -599,12 +599,12 @@ gimp_navigation_view_scroll (GimpNavigationPreview *preview,
{
case GDK_SCROLL_LEFT:
case GDK_SCROLL_RIGHT:
adj = view->shell->hsbdata;
adj = editor->shell->hsbdata;
break;
case GDK_SCROLL_UP:
case GDK_SCROLL_DOWN:
adj = view->shell->vsbdata;
adj = editor->shell->vsbdata;
break;
}
@ -632,131 +632,131 @@ gimp_navigation_view_scroll (GimpNavigationPreview *preview,
}
static void
gimp_navigation_view_zoom_adj_changed (GtkAdjustment *adj,
GimpNavigationView *view)
gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
GimpNavigationEditor *editor)
{
gimp_display_shell_scale (view->shell, GIMP_ZOOM_TO,
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_TO,
pow (2.0, adj->value));
}
static void
gimp_navigation_view_zoom_out_clicked (GtkWidget *widget,
GimpNavigationView *view)
gimp_navigation_editor_zoom_out_clicked (GtkWidget *widget,
GimpNavigationEditor *editor)
{
if (view->shell)
gimp_display_shell_scale (view->shell, GIMP_ZOOM_OUT, 0.0);
if (editor->shell)
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_OUT, 0.0);
}
static void
gimp_navigation_view_zoom_in_clicked (GtkWidget *widget,
GimpNavigationView *view)
gimp_navigation_editor_zoom_in_clicked (GtkWidget *widget,
GimpNavigationEditor *editor)
{
if (view->shell)
gimp_display_shell_scale (view->shell, GIMP_ZOOM_IN, 0.0);
if (editor->shell)
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_IN, 0.0);
}
static void
gimp_navigation_view_zoom_100_clicked (GtkWidget *widget,
GimpNavigationView *view)
gimp_navigation_editor_zoom_100_clicked (GtkWidget *widget,
GimpNavigationEditor *editor)
{
if (view->shell)
gimp_display_shell_scale (view->shell, GIMP_ZOOM_TO, 1.0);
if (editor->shell)
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_TO, 1.0);
}
static void
gimp_navigation_view_zoom_fit_in_clicked (GtkWidget *widget,
GimpNavigationView *view)
gimp_navigation_editor_zoom_fit_in_clicked (GtkWidget *widget,
GimpNavigationEditor *editor)
{
if (view->shell)
gimp_display_shell_scale_fit_in (view->shell);
if (editor->shell)
gimp_display_shell_scale_fit_in (editor->shell);
}
static void
gimp_navigation_view_zoom_fit_to_clicked (GtkWidget *widget,
GimpNavigationView *view)
gimp_navigation_editor_zoom_fit_to_clicked (GtkWidget *widget,
GimpNavigationEditor *editor)
{
if (view->shell)
gimp_display_shell_scale_fit_to (view->shell);
if (editor->shell)
gimp_display_shell_scale_fit_to (editor->shell);
}
static void
gimp_navigation_view_shrink_clicked (GtkWidget *widget,
GimpNavigationView *view)
gimp_navigation_editor_shrink_clicked (GtkWidget *widget,
GimpNavigationEditor *editor)
{
if (view->shell)
gimp_display_shell_scale_shrink_wrap (view->shell);
if (editor->shell)
gimp_display_shell_scale_shrink_wrap (editor->shell);
}
static void
gimp_navigation_view_shell_scaled (GimpDisplayShell *shell,
GimpNavigationView *view)
gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
GimpNavigationEditor *editor)
{
if (view->zoom_label)
if (editor->zoom_label)
{
gchar scale_str[MAX_SCALE_BUF];
/* Update the zoom scale string */
g_snprintf (scale_str, sizeof (scale_str),
shell->scale >= 0.15 ? "%.0f%%" : "%.2f%%",
view->shell->scale * 100);
editor->shell->scale * 100);
gtk_label_set_text (GTK_LABEL (view->zoom_label), scale_str);
gtk_label_set_text (GTK_LABEL (editor->zoom_label), scale_str);
}
if (view->zoom_adjustment)
if (editor->zoom_adjustment)
{
gdouble val;
val = log (CLAMP (view->shell->scale, 1.0 / 256, 256.0) ) / G_LN2;
val = log (CLAMP (editor->shell->scale, 1.0 / 256, 256.0) ) / G_LN2;
g_signal_handlers_block_by_func (view->zoom_adjustment,
gimp_navigation_view_zoom_adj_changed,
view);
g_signal_handlers_block_by_func (editor->zoom_adjustment,
gimp_navigation_editor_zoom_adj_changed,
editor);
gtk_adjustment_set_value (view->zoom_adjustment, val);
gtk_adjustment_set_value (editor->zoom_adjustment, val);
g_signal_handlers_unblock_by_func (view->zoom_adjustment,
gimp_navigation_view_zoom_adj_changed,
view);
g_signal_handlers_unblock_by_func (editor->zoom_adjustment,
gimp_navigation_editor_zoom_adj_changed,
editor);
}
gimp_navigation_view_update_marker (view);
gimp_navigation_editor_update_marker (editor);
}
static void
gimp_navigation_view_shell_scrolled (GimpDisplayShell *shell,
GimpNavigationView *view)
gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
GimpNavigationEditor *editor)
{
gimp_navigation_view_update_marker (view);
gimp_navigation_editor_update_marker (editor);
}
static void
gimp_navigation_view_shell_reconnect (GimpDisplayShell *shell,
GimpNavigationView *view)
gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
GimpNavigationEditor *editor)
{
gimp_view_set_viewable (GIMP_VIEW (view->preview),
gimp_view_set_viewable (GIMP_VIEW (editor->preview),
GIMP_VIEWABLE (shell->gdisp->gimage));
}
static void
gimp_navigation_view_update_marker (GimpNavigationView *view)
gimp_navigation_editor_update_marker (GimpNavigationEditor *editor)
{
GimpPreviewRenderer *renderer;
gdouble xratio;
gdouble yratio;
renderer = GIMP_VIEW (view->preview)->renderer;
renderer = GIMP_VIEW (editor->preview)->renderer;
xratio = SCALEFACTOR_X (view->shell);
yratio = SCALEFACTOR_Y (view->shell);
xratio = SCALEFACTOR_X (editor->shell);
yratio = SCALEFACTOR_Y (editor->shell);
if (renderer->dot_for_dot != view->shell->dot_for_dot)
if (renderer->dot_for_dot != editor->shell->dot_for_dot)
gimp_preview_renderer_set_dot_for_dot (renderer,
view->shell->dot_for_dot);
editor->shell->dot_for_dot);
gimp_navigation_preview_set_marker (GIMP_NAVIGATION_PREVIEW (view->preview),
view->shell->offset_x / xratio,
view->shell->offset_y / yratio,
view->shell->disp_width / xratio,
view->shell->disp_height / yratio);
gimp_navigation_preview_set_marker (GIMP_NAVIGATION_PREVIEW (editor->preview),
editor->shell->offset_x / xratio,
editor->shell->offset_y / yratio,
editor->shell->disp_width / xratio,
editor->shell->disp_height / yratio);
}

View File

@ -1,7 +1,7 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpnavigationview.h
* gimpnavigationeditor.h
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
*
* partly based on app/nav_window
@ -22,24 +22,24 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_NAVIGATION_VIEW_H__
#define __GIMP_NAVIGATION_VIEW_H__
#ifndef __GIMP_NAVIGATION_EDITOR_H__
#define __GIMP_NAVIGATION_EDITOR_H__
#include "widgets/gimpeditor.h"
#define GIMP_TYPE_NAVIGATION_VIEW (gimp_navigation_view_get_type ())
#define GIMP_NAVIGATION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NAVIGATION_VIEW, GimpNavigationView))
#define GIMP_NAVIGATION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NAVIGATION_VIEW, GimpNavigationViewClass))
#define GIMP_IS_NAVIGATION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NAVIGATION_VIEW))
#define GIMP_IS_NAVIGATION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NAVIGATION_VIEW))
#define GIMP_NAVIGATION_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NAVIGATION_VIEW, GimpNavigationViewClass))
#define GIMP_TYPE_NAVIGATION_EDITOR (gimp_navigation_editor_get_type ())
#define GIMP_NAVIGATION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NAVIGATION_EDITOR, GimpNavigationEditor))
#define GIMP_NAVIGATION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NAVIGATION_EDITOR, GimpNavigationEditorClass))
#define GIMP_IS_NAVIGATION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NAVIGATION_EDITOR))
#define GIMP_IS_NAVIGATION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NAVIGATION_EDITOR))
#define GIMP_NAVIGATION_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NAVIGATION_EDITOR, GimpNavigationEditorClass))
typedef struct _GimpNavigationViewClass GimpNavigationViewClass;
typedef struct _GimpNavigationEditorClass GimpNavigationEditorClass;
struct _GimpNavigationView
struct _GimpNavigationEditor
{
GimpEditor parent_instance;
@ -58,23 +58,23 @@ struct _GimpNavigationView
GtkWidget *shrink_wrap_button;
};
struct _GimpNavigationViewClass
struct _GimpNavigationEditorClass
{
GimpEditorClass parent_class;
};
GType gimp_navigation_view_get_type (void) G_GNUC_CONST;
GType gimp_navigation_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_navigation_view_new (GimpDisplayShell *shell,
GimpDisplayConfig *config);
void gimp_navigation_view_set_shell (GimpNavigationView *view,
GimpDisplayShell *shell);
GtkWidget * gimp_navigation_editor_new (GimpDisplayShell *shell,
GimpDisplayConfig *config);
void gimp_navigation_editor_set_shell (GimpNavigationEditor *view,
GimpDisplayShell *shell);
void gimp_navigation_view_popup (GimpDisplayShell *shell,
GtkWidget *widget,
gint click_x,
gint click_y);
void gimp_navigation_editor_popup (GimpDisplayShell *shell,
GtkWidget *widget,
gint click_x,
gint click_y);
#endif /* __GIMP_NAVIGATION_VIEW_H__ */
#endif /* __GIMP_NAVIGATION_EDITOR_H__ */

View File

@ -1,762 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpnavigationview.c
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
*
* partly based on app/nav_window
* Copyright (C) 1999 Andy Thomas <alt@gimp.org>
*
* 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"
#include "display-types.h"
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "widgets/gimpdocked.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpnavigationpreview.h"
#include "widgets/gimppreviewrenderer.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpnavigationview.h"
#include "gimp-intl.h"
#define MAX_SCALE_BUF 20
static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass);
static void gimp_navigation_view_init (GimpNavigationView *view);
static void gimp_navigation_view_docked_iface_init (GimpDockedInterface *docked_iface);
static void gimp_navigation_view_set_context (GimpDocked *docked,
GimpContext *context);
static void gimp_navigation_view_destroy (GtkObject *object);
static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
GimpDisplayConfig *config,
gboolean popup);
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell);
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gdouble x,
gdouble y,
GimpNavigationView *view);
static void gimp_navigation_view_zoom (GimpNavigationPreview *preview,
GimpZoomType direction,
GimpNavigationView *view);
static void gimp_navigation_view_scroll (GimpNavigationPreview *preview,
GdkScrollDirection direction,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_adj_changed (GtkAdjustment *adj,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_out_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_in_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_100_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_fit_in_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_zoom_fit_to_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_shrink_clicked (GtkWidget *widget,
GimpNavigationView *view);
static void gimp_navigation_view_shell_scaled (GimpDisplayShell *shell,
GimpNavigationView *view);
static void gimp_navigation_view_shell_scrolled (GimpDisplayShell *shell,
GimpNavigationView *view);
static void gimp_navigation_view_shell_reconnect (GimpDisplayShell *shell,
GimpNavigationView *view);
static void gimp_navigation_view_update_marker (GimpNavigationView *view);
static GimpEditorClass *parent_class = NULL;
GType
gimp_navigation_view_get_type (void)
{
static GType type = 0;
if (! type)
{
static const GTypeInfo view_info =
{
sizeof (GimpNavigationViewClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_navigation_view_class_init,
NULL, /* class_finalize */
NULL, /* class_navigation */
sizeof (GimpNavigationView),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_navigation_view_init,
};
static const GInterfaceInfo docked_iface_info =
{
(GInterfaceInitFunc) gimp_navigation_view_docked_iface_init,
NULL, /* iface_finalize */
NULL /* iface_data */
};
type = g_type_register_static (GIMP_TYPE_EDITOR,
"GimpNavigationView",
&view_info, 0);
g_type_add_interface_static (type, GIMP_TYPE_DOCKED,
&docked_iface_info);
}
return type;
}
static void
gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
{
GObjectClass *object_class;
GtkObjectClass *gtk_object_class;
object_class = G_OBJECT_CLASS (klass);
gtk_object_class = GTK_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
gtk_object_class->destroy = gimp_navigation_view_destroy;
}
static void
gimp_navigation_view_init (GimpNavigationView *view)
{
GtkWidget *frame;
view->shell = NULL;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (view), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
view->preview = gimp_view_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
GIMP_TYPE_IMAGE,
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
gtk_container_add (GTK_CONTAINER (frame), view->preview);
gtk_widget_show (view->preview);
g_signal_connect (view->preview, "marker_changed",
G_CALLBACK (gimp_navigation_view_marker_changed),
view);
g_signal_connect (view->preview, "zoom",
G_CALLBACK (gimp_navigation_view_zoom),
view);
g_signal_connect (view->preview, "scroll",
G_CALLBACK (gimp_navigation_view_scroll),
view);
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
}
static void
gimp_navigation_view_docked_iface_init (GimpDockedInterface *docked_iface)
{
docked_iface->set_context = gimp_navigation_view_set_context;
}
static void
gimp_navigation_view_context_changed (GimpContext *context,
GimpDisplay *gdisp,
GimpNavigationView *view)
{
GimpDisplayShell *shell = NULL;
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_set_context (GimpDocked *docked,
GimpContext *context)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (docked);
GimpDisplay *gdisp = NULL;
GimpDisplayShell *shell = NULL;
if (view->context)
{
g_signal_handlers_disconnect_by_func (view->context,
gimp_navigation_view_context_changed,
view);
}
view->context = context;
if (context)
{
g_signal_connect (context, "display_changed",
G_CALLBACK (gimp_navigation_view_context_changed),
view);
gdisp = gimp_context_get_display (context);
}
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
gimp_navigation_view_set_shell (view, shell);
}
static void
gimp_navigation_view_destroy (GtkObject *object)
{
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (object);
if (view->shell)
gimp_navigation_view_set_shell (view, NULL);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
/* public functions */
GtkWidget *
gimp_navigation_view_new (GimpDisplayShell *shell,
GimpDisplayConfig *config)
{
return gimp_navigation_view_new_private (shell, config, FALSE);
}
void
gimp_navigation_view_set_shell (GimpNavigationView *view,
GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (view));
g_return_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell));
if (shell == view->shell)
return;
if (view->shell)
{
g_signal_handlers_disconnect_by_func (view->shell,
gimp_navigation_view_shell_scaled,
view);
g_signal_handlers_disconnect_by_func (view->shell,
gimp_navigation_view_shell_scrolled,
view);
g_signal_handlers_disconnect_by_func (view->shell,
gimp_navigation_view_shell_reconnect,
view);
}
else if (shell)
{
gtk_widget_set_sensitive (GTK_WIDGET (view), TRUE);
}
view->shell = shell;
if (view->shell)
{
gimp_view_set_viewable (GIMP_VIEW (view->preview),
GIMP_VIEWABLE (shell->gdisp->gimage));
g_signal_connect (view->shell, "scaled",
G_CALLBACK (gimp_navigation_view_shell_scaled),
view);
g_signal_connect (view->shell, "scrolled",
G_CALLBACK (gimp_navigation_view_shell_scrolled),
view);
g_signal_connect (view->shell, "reconnect",
G_CALLBACK (gimp_navigation_view_shell_reconnect),
view);
gimp_navigation_view_shell_scaled (view->shell, view);
}
else
{
gimp_view_set_viewable (GIMP_VIEW (view->preview), NULL);
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
}
}
void
gimp_navigation_view_popup (GimpDisplayShell *shell,
GtkWidget *widget,
gint click_x,
gint click_y)
{
GimpNavigationView *view;
GimpNavigationPreview *preview;
GdkScreen *screen;
gint x, y;
gint x_org, y_org;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GTK_IS_WIDGET (widget));
if (! shell->nav_popup)
{
GimpDisplayConfig *config;
GtkWidget *frame;
shell->nav_popup = gtk_window_new (GTK_WINDOW_POPUP);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (shell->nav_popup), frame);
gtk_widget_show (frame);
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
view = GIMP_NAVIGATION_VIEW (gimp_navigation_view_new_private (shell,
config,
TRUE));
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view));
gtk_widget_show (GTK_WIDGET (view));
g_signal_connect (view->preview, "button_release_event",
G_CALLBACK (gimp_navigation_view_button_release),
shell);
}
else
{
view = GIMP_NAVIGATION_VIEW (GTK_BIN (GTK_BIN (shell->nav_popup)->child)->child);
}
screen = gtk_widget_get_screen (widget);
gtk_window_set_screen (GTK_WINDOW (shell->nav_popup), screen);
preview = GIMP_NAVIGATION_PREVIEW (view->preview);
/* decide where to put the popup */
gdk_window_get_origin (widget->window, &x_org, &y_org);
#define BORDER_PEN_WIDTH 3
x = (x_org + click_x -
preview->p_x -
0.5 * (preview->p_width - BORDER_PEN_WIDTH) -
2 * widget->style->xthickness);
y = (y_org + click_y -
preview->p_y -
0.5 * (preview->p_height - BORDER_PEN_WIDTH) -
2 * widget->style->ythickness);
/* 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 = CLAMP (x, 0, (gdk_screen_get_width (screen) -
GIMP_VIEW (preview)->renderer->width -
4 * widget->style->xthickness));
y = CLAMP (y, 0, (gdk_screen_get_height (screen) -
GIMP_VIEW (preview)->renderer->height -
4 * widget->style->ythickness));
gtk_window_move (GTK_WINDOW (shell->nav_popup), x, y);
gtk_widget_show (shell->nav_popup);
gdk_flush ();
/* fill in then grab pointer */
preview->motion_offset_x = 0.5 * (preview->p_width - BORDER_PEN_WIDTH);
preview->motion_offset_y = 0.5 * (preview->p_height - BORDER_PEN_WIDTH);
#undef BORDER_PEN_WIDTH
gimp_navigation_preview_grab_pointer (preview);
}
/* private functions */
static GtkWidget *
gimp_navigation_view_new_private (GimpDisplayShell *shell,
GimpDisplayConfig *config,
gboolean popup)
{
GimpNavigationView *view;
g_return_val_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell), NULL);
g_return_val_if_fail (GIMP_IS_DISPLAY_CONFIG (config), NULL);
g_return_val_if_fail (! popup || (popup && shell), NULL);
view = g_object_new (GIMP_TYPE_NAVIGATION_VIEW, NULL);
if (popup)
{
GimpView *preview = GIMP_VIEW (view->preview);
gimp_preview_renderer_set_size (preview->renderer,
config->nav_preview_size * 3,
preview->renderer->border_width);
}
else
{
GtkWidget *hscale;
gtk_widget_set_size_request (view->preview,
GIMP_PREVIEW_SIZE_HUGE,
GIMP_PREVIEW_SIZE_HUGE);
gimp_view_set_expand (GIMP_VIEW (view->preview), TRUE);
/* the editor buttons */
view->zoom_out_button =
gimp_editor_add_button (GIMP_EDITOR (view),
GTK_STOCK_ZOOM_OUT, _("Zoom out"),
GIMP_HELP_VIEW_ZOOM_OUT,
G_CALLBACK (gimp_navigation_view_zoom_out_clicked),
NULL,
view);
view->zoom_in_button =
gimp_editor_add_button (GIMP_EDITOR (view),
GTK_STOCK_ZOOM_IN, _("Zoom in"),
GIMP_HELP_VIEW_ZOOM_IN,
G_CALLBACK (gimp_navigation_view_zoom_in_clicked),
NULL,
view);
view->zoom_100_button =
gimp_editor_add_button (GIMP_EDITOR (view),
GTK_STOCK_ZOOM_100, _("Zoom 1:1"),
GIMP_HELP_VIEW_ZOOM_100,
G_CALLBACK (gimp_navigation_view_zoom_100_clicked),
NULL,
view);
view->zoom_fit_in_button =
gimp_editor_add_button (GIMP_EDITOR (view),
GTK_STOCK_ZOOM_FIT, _("Fit Image in Window"),
GIMP_HELP_VIEW_ZOOM_FIT_IN,
G_CALLBACK (gimp_navigation_view_zoom_fit_in_clicked),
NULL,
view);
view->zoom_fit_to_button =
gimp_editor_add_button (GIMP_EDITOR (view),
GTK_STOCK_ZOOM_FIT, _("Fit Image to Window"),
GIMP_HELP_VIEW_ZOOM_FIT_TO,
G_CALLBACK (gimp_navigation_view_zoom_fit_to_clicked),
NULL,
view);
view->shrink_wrap_button =
gimp_editor_add_button (GIMP_EDITOR (view),
GTK_STOCK_ZOOM_FIT, _("Shrink Wrap"),
GIMP_HELP_VIEW_SHRINK_WRAP,
G_CALLBACK (gimp_navigation_view_shrink_clicked),
NULL,
view);
/* the zoom scale */
view->zoom_adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -8.0, 8.0, 0.5, 1.0, 0.0));
g_signal_connect (view->zoom_adjustment, "value_changed",
G_CALLBACK (gimp_navigation_view_zoom_adj_changed),
view);
hscale = gtk_hscale_new (GTK_ADJUSTMENT (view->zoom_adjustment));
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_DELAYED);
gtk_scale_set_draw_value (GTK_SCALE (hscale), FALSE);
gtk_scale_set_digits (GTK_SCALE (hscale), 2);
gtk_box_pack_end (GTK_BOX (view), hscale, FALSE, FALSE, 0);
gtk_widget_show (hscale);
/* the zoom label */
view->zoom_label = gtk_label_new ("100%");
gtk_box_pack_end (GTK_BOX (view), view->zoom_label, FALSE, FALSE, 0);
gtk_widget_show (view->zoom_label);
/* eek */
{
GtkRequisition requisition;
gtk_widget_size_request (view->zoom_label, &requisition);
gtk_widget_set_size_request (view->zoom_label,
4 * requisition.width,
requisition.height);
}
}
if (shell)
gimp_navigation_view_set_shell (view, shell);
gimp_preview_renderer_set_background (GIMP_VIEW (view->preview)->renderer,
GIMP_STOCK_TEXTURE);
return GTK_WIDGET (view);
}
static gboolean
gimp_navigation_view_button_release (GtkWidget *widget,
GdkEventButton *bevent,
GimpDisplayShell *shell)
{
if (bevent->button == 1)
{
gtk_widget_hide (shell->nav_popup);
}
return FALSE;
}
static void
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
gdouble x,
gdouble y,
GimpNavigationView *view)
{
if (view->shell)
{
gdouble xratio;
gdouble yratio;
gint xoffset;
gint yoffset;
xratio = SCALEFACTOR_X (view->shell);
yratio = SCALEFACTOR_Y (view->shell);
xoffset = RINT (x * xratio - view->shell->offset_x);
yoffset = RINT (y * yratio - view->shell->offset_y);
gimp_display_shell_scroll (view->shell, xoffset, yoffset);
}
}
static void
gimp_navigation_view_zoom (GimpNavigationPreview *preview,
GimpZoomType direction,
GimpNavigationView *view)
{
g_return_if_fail (direction != GIMP_ZOOM_TO);
if (view->shell)
{
gimp_display_shell_scale (view->shell, direction, 0.0);
}
}
static void
gimp_navigation_view_scroll (GimpNavigationPreview *preview,
GdkScrollDirection direction,
GimpNavigationView *view)
{
if (view->shell)
{
GtkAdjustment *adj = NULL;
gdouble value;
switch (direction)
{
case GDK_SCROLL_LEFT:
case GDK_SCROLL_RIGHT:
adj = view->shell->hsbdata;
break;
case GDK_SCROLL_UP:
case GDK_SCROLL_DOWN:
adj = view->shell->vsbdata;
break;
}
g_assert (adj != NULL);
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);
}
}
static void
gimp_navigation_view_zoom_adj_changed (GtkAdjustment *adj,
GimpNavigationView *view)
{
gimp_display_shell_scale (view->shell, GIMP_ZOOM_TO,
pow (2.0, adj->value));
}
static void
gimp_navigation_view_zoom_out_clicked (GtkWidget *widget,
GimpNavigationView *view)
{
if (view->shell)
gimp_display_shell_scale (view->shell, GIMP_ZOOM_OUT, 0.0);
}
static void
gimp_navigation_view_zoom_in_clicked (GtkWidget *widget,
GimpNavigationView *view)
{
if (view->shell)
gimp_display_shell_scale (view->shell, GIMP_ZOOM_IN, 0.0);
}
static void
gimp_navigation_view_zoom_100_clicked (GtkWidget *widget,
GimpNavigationView *view)
{
if (view->shell)
gimp_display_shell_scale (view->shell, GIMP_ZOOM_TO, 1.0);
}
static void
gimp_navigation_view_zoom_fit_in_clicked (GtkWidget *widget,
GimpNavigationView *view)
{
if (view->shell)
gimp_display_shell_scale_fit_in (view->shell);
}
static void
gimp_navigation_view_zoom_fit_to_clicked (GtkWidget *widget,
GimpNavigationView *view)
{
if (view->shell)
gimp_display_shell_scale_fit_to (view->shell);
}
static void
gimp_navigation_view_shrink_clicked (GtkWidget *widget,
GimpNavigationView *view)
{
if (view->shell)
gimp_display_shell_scale_shrink_wrap (view->shell);
}
static void
gimp_navigation_view_shell_scaled (GimpDisplayShell *shell,
GimpNavigationView *view)
{
if (view->zoom_label)
{
gchar scale_str[MAX_SCALE_BUF];
/* Update the zoom scale string */
g_snprintf (scale_str, sizeof (scale_str),
shell->scale >= 0.15 ? "%.0f%%" : "%.2f%%",
view->shell->scale * 100);
gtk_label_set_text (GTK_LABEL (view->zoom_label), scale_str);
}
if (view->zoom_adjustment)
{
gdouble val;
val = log (CLAMP (view->shell->scale, 1.0 / 256, 256.0) ) / G_LN2;
g_signal_handlers_block_by_func (view->zoom_adjustment,
gimp_navigation_view_zoom_adj_changed,
view);
gtk_adjustment_set_value (view->zoom_adjustment, val);
g_signal_handlers_unblock_by_func (view->zoom_adjustment,
gimp_navigation_view_zoom_adj_changed,
view);
}
gimp_navigation_view_update_marker (view);
}
static void
gimp_navigation_view_shell_scrolled (GimpDisplayShell *shell,
GimpNavigationView *view)
{
gimp_navigation_view_update_marker (view);
}
static void
gimp_navigation_view_shell_reconnect (GimpDisplayShell *shell,
GimpNavigationView *view)
{
gimp_view_set_viewable (GIMP_VIEW (view->preview),
GIMP_VIEWABLE (shell->gdisp->gimage));
}
static void
gimp_navigation_view_update_marker (GimpNavigationView *view)
{
GimpPreviewRenderer *renderer;
gdouble xratio;
gdouble yratio;
renderer = GIMP_VIEW (view->preview)->renderer;
xratio = SCALEFACTOR_X (view->shell);
yratio = SCALEFACTOR_Y (view->shell);
if (renderer->dot_for_dot != view->shell->dot_for_dot)
gimp_preview_renderer_set_dot_for_dot (renderer,
view->shell->dot_for_dot);
gimp_navigation_preview_set_marker (GIMP_NAVIGATION_PREVIEW (view->preview),
view->shell->offset_x / xratio,
view->shell->offset_y / yratio,
view->shell->disp_width / xratio,
view->shell->disp_height / yratio);
}

View File

@ -1,80 +0,0 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpnavigationview.h
* Copyright (C) 2002 Michael Natterer <mitch@gimp.org>
*
* partly based on app/nav_window
* Copyright (C) 1999 Andy Thomas <alt@gimp.org>
*
* 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.
*/
#ifndef __GIMP_NAVIGATION_VIEW_H__
#define __GIMP_NAVIGATION_VIEW_H__
#include "widgets/gimpeditor.h"
#define GIMP_TYPE_NAVIGATION_VIEW (gimp_navigation_view_get_type ())
#define GIMP_NAVIGATION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_NAVIGATION_VIEW, GimpNavigationView))
#define GIMP_NAVIGATION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_NAVIGATION_VIEW, GimpNavigationViewClass))
#define GIMP_IS_NAVIGATION_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_NAVIGATION_VIEW))
#define GIMP_IS_NAVIGATION_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_NAVIGATION_VIEW))
#define GIMP_NAVIGATION_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_NAVIGATION_VIEW, GimpNavigationViewClass))
typedef struct _GimpNavigationViewClass GimpNavigationViewClass;
struct _GimpNavigationView
{
GimpEditor parent_instance;
GimpContext *context;
GimpDisplayShell *shell;
GtkWidget *preview;
GtkWidget *zoom_label;
GtkAdjustment *zoom_adjustment;
GtkWidget *zoom_out_button;
GtkWidget *zoom_in_button;
GtkWidget *zoom_100_button;
GtkWidget *zoom_fit_in_button;
GtkWidget *zoom_fit_to_button;
GtkWidget *shrink_wrap_button;
};
struct _GimpNavigationViewClass
{
GimpEditorClass parent_class;
};
GType gimp_navigation_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_navigation_view_new (GimpDisplayShell *shell,
GimpDisplayConfig *config);
void gimp_navigation_view_set_shell (GimpNavigationView *view,
GimpDisplayShell *shell);
void gimp_navigation_view_popup (GimpDisplayShell *shell,
GtkWidget *widget,
gint click_x,
gint click_y);
#endif /* __GIMP_NAVIGATION_VIEW_H__ */

View File

@ -68,7 +68,7 @@
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpnavigationview.h"
#include "display/gimpnavigationeditor.h"
#include "actions/channels-commands.h"
#include "actions/edit-commands.h"
@ -829,8 +829,8 @@ dialogs_navigation_view_new (GimpDialogFactory *factory,
if (gdisp)
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
view = gimp_navigation_view_new (shell,
GIMP_DISPLAY_CONFIG (context->gimp->config));
view = gimp_navigation_editor_new (shell,
GIMP_DISPLAY_CONFIG (context->gimp->config));
return dialogs_dockable_new (view,
_("Navigation"), _("Display Navigation"),