From b6c56ff9ac0f09b4684c6be6c1c36779d7875914 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 7 May 2002 16:23:14 +0000 Subject: [PATCH] app/Makefile.am removed. 2002-05-07 Michael Natterer * app/Makefile.am * app/nav_window.[ch]: removed. * app/display/Makefile.am * app/display/display-types.h * app/display/gimpnavigationview.[ch]: new widget partially based on the removed nav_window. * libgimpproxy/gimpproxytypes.h: regnenerated. * app/display/gimpdisplay-foreach.[ch]: removed gdisplays_nav_preview_resized(). The new config system will allow us to get notified of changes. * app/display/gimpdisplayshell.[ch]: added "scaled" and "scrolled" signals. * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c: emit "scaled" and "scrolled" appropriately. Removed nav_window stuff. * app/display/gimpdisplay.c * app/display/gimpdisplayshell-callbacks.c: changed accordingly. * app/gui/dialogs-constructors.[ch] * app/gui/dialogs.c * app/gui/menus.c: made the navigation dialog dockable. * app/gui/view-commands.c: changed the nav_dialog callback accordingly. * app/gui/preferences-dialog.c * app/gimprc.[ch] * app/config/gimpguiconfig.[ch]: removed "nav_window_per_display" as it's now a dockable and it's state is saved in sessionrc. * app/widgets/gimpnavigationpreview.[ch]: added context sensitive mouse cursors. * app/widgets/gimpimagedock.c: made it capable of holding display-related dialogs (like GimpNavigationView) by connecting to the context's "display_changed" signal. * app/widgets/widgets-types.h: removed inclusion of "display/display-types.h". * app/widgets/gimpbufferview.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolormapeditor.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpdocumentview.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpitemlistitem.c * app/widgets/gimpitemlistview.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplayerlistview.c * app/widgets/gimppreview.c * app/widgets/gimpvectorslistview.c: warn about inclusion of "display/display-types.h". --- ChangeLog | 62 ++ app/Makefile.am | 2 - app/actions/view-commands.c | 14 +- app/config/gimpguiconfig.c | 10 - app/config/gimpguiconfig.h | 1 - app/core/gimpprojection.c | 1 - app/dialogs/dialogs-constructors.c | 79 ++ app/dialogs/dialogs-constructors.h | 4 + app/dialogs/dialogs.c | 4 +- app/dialogs/preferences-dialog.c | 22 +- app/display/Makefile.am | 2 + app/display/display-types.h | 11 +- app/display/gimpdisplay-foreach.c | 23 - app/display/gimpdisplay-foreach.h | 1 - app/display/gimpdisplay.c | 1 - app/display/gimpdisplayshell-callbacks.c | 4 +- app/display/gimpdisplayshell-draw.c | 54 +- app/display/gimpdisplayshell-draw.h | 9 +- app/display/gimpdisplayshell-scale.c | 6 +- app/display/gimpdisplayshell-scroll.c | 6 +- app/display/gimpdisplayshell.c | 54 +- app/display/gimpdisplayshell.h | 9 +- app/display/gimpnavigationeditor.c | 1036 ++++++++++------------ app/display/gimpnavigationeditor.h | 77 ++ app/display/gimpnavigationview.c | 1036 ++++++++++------------ app/display/gimpnavigationview.h | 77 ++ app/gimprc.c | 3 - app/gimprc.h | 1 - app/gui/dialogs-constructors.c | 79 ++ app/gui/dialogs-constructors.h | 4 + app/gui/dialogs.c | 4 +- app/gui/menus.c | 9 +- app/gui/preferences-dialog.c | 22 +- app/gui/view-commands.c | 14 +- app/menus/menus.c | 9 +- app/nav_window.c | 745 ---------------- app/nav_window.h | 39 - app/widgets/gimpbufferview.c | 3 + app/widgets/gimpchannellistview.c | 3 + app/widgets/gimpchanneltreeview.c | 3 + app/widgets/gimpcolormapeditor.c | 3 + app/widgets/gimpcomponentlistitem.c | 3 + app/widgets/gimpdocumentview.c | 3 + app/widgets/gimpdrawablelistitem.c | 3 + app/widgets/gimpdrawablelistview.c | 3 + app/widgets/gimpdrawabletreeview.c | 3 + app/widgets/gimpimagedock.c | 69 +- app/widgets/gimpitemlistitem.c | 3 + app/widgets/gimpitemlistview.c | 3 + app/widgets/gimpitemtreeview.c | 3 + app/widgets/gimplayerlistitem.c | 3 + app/widgets/gimplayerlistview.c | 3 + app/widgets/gimplayertreeview.c | 3 + app/widgets/gimpmenudock.c | 69 +- app/widgets/gimpnavigationpreview.c | 62 +- app/widgets/gimpnavigationpreview.h | 5 +- app/widgets/gimpnavigationview.c | 62 +- app/widgets/gimpnavigationview.h | 5 +- app/widgets/gimppreview.c | 3 + app/widgets/gimppreviewrenderer.c | 3 + app/widgets/gimpvectorslistview.c | 3 + app/widgets/gimpvectorstreeview.c | 3 + app/widgets/gimpview.c | 3 + app/widgets/gimpviewrenderer.c | 3 + app/widgets/widgets-types.h | 2 - libgimpproxy/gimpproxytypes.h | 4 +- 66 files changed, 1735 insertions(+), 2140 deletions(-) create mode 100644 app/display/gimpnavigationeditor.h create mode 100644 app/display/gimpnavigationview.h delete mode 100644 app/nav_window.c delete mode 100644 app/nav_window.h diff --git a/ChangeLog b/ChangeLog index e60c535b9a..213e19363f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,65 @@ +2002-05-07 Michael Natterer + + * app/Makefile.am + * app/nav_window.[ch]: removed. + + * app/display/Makefile.am + * app/display/display-types.h + * app/display/gimpnavigationview.[ch]: new widget partially based + on the removed nav_window. + + * libgimpproxy/gimpproxytypes.h: regnenerated. + + * app/display/gimpdisplay-foreach.[ch]: removed + gdisplays_nav_preview_resized(). The new config system will allow + us to get notified of changes. + + * app/display/gimpdisplayshell.[ch]: added "scaled" and "scrolled" + signals. + + * app/display/gimpdisplayshell-scale.c + * app/display/gimpdisplayshell-scroll.c: emit "scaled" and + "scrolled" appropriately. Removed nav_window stuff. + + * app/display/gimpdisplay.c + * app/display/gimpdisplayshell-callbacks.c: changed accordingly. + + * app/gui/dialogs-constructors.[ch] + * app/gui/dialogs.c + * app/gui/menus.c: made the navigation dialog dockable. + + * app/gui/view-commands.c: changed the nav_dialog callback accordingly. + + * app/gui/preferences-dialog.c + * app/gimprc.[ch] + * app/config/gimpguiconfig.[ch]: removed "nav_window_per_display" + as it's now a dockable and it's state is saved in sessionrc. + + * app/widgets/gimpnavigationpreview.[ch]: added context sensitive + mouse cursors. + + * app/widgets/gimpimagedock.c: made it capable of holding + display-related dialogs (like GimpNavigationView) by connecting + to the context's "display_changed" signal. + + * app/widgets/widgets-types.h: removed inclusion of + "display/display-types.h". + + * app/widgets/gimpbufferview.c + * app/widgets/gimpchannellistview.c + * app/widgets/gimpcolormapeditor.c + * app/widgets/gimpcomponentlistitem.c + * app/widgets/gimpdocumentview.c + * app/widgets/gimpdrawablelistitem.c + * app/widgets/gimpdrawablelistview.c + * app/widgets/gimpitemlistitem.c + * app/widgets/gimpitemlistview.c + * app/widgets/gimplayerlistitem.c + * app/widgets/gimplayerlistview.c + * app/widgets/gimppreview.c + * app/widgets/gimpvectorslistview.c: warn about inclusion of + "display/display-types.h". + 2002-05-07 Sven Neumann Moved slovenian translation to the stable branch where they should diff --git a/app/Makefile.am b/app/Makefile.am index aae84b4b27..b6f3a0b134 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -24,8 +24,6 @@ bin_PROGRAMS = gimp-1.3 ## gui stuff for gui/, display/ or widgets/ ## gui_sources = \ - nav_window.c \ - nav_window.h \ undo_history.c \ undo_history.h diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c index d5d957e91a..a83d17ff22 100644 --- a/app/actions/view-commands.c +++ b/app/actions/view-commands.c @@ -42,7 +42,6 @@ #include "view-commands.h" #include "gimprc.h" -#include "nav_window.h" #define return_if_no_display(gdisp, data) \ @@ -136,17 +135,8 @@ view_navigation_window_cmd_callback (GtkWidget *widget, shell = GIMP_DISPLAY_SHELL (gdisp->shell); - if (gimprc.nav_window_per_display) - { - if (! shell->nav_dialog) - shell->nav_dialog = nav_dialog_create (shell); - - nav_dialog_show (shell->nav_dialog); - } - else - { - nav_dialog_show_auto (gdisp->gimage->gimp); - } + gimp_dialog_factory_dialog_raise (global_dock_factory, + "gimp-navigation-view", -1); } void diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c index ff6ff18f6c..5210cb4a45 100644 --- a/app/config/gimpguiconfig.c +++ b/app/config/gimpguiconfig.c @@ -52,7 +52,6 @@ enum PROP_PERFECT_MOUSE, PROP_DEFAULT_THRESHOLD, PROP_NAV_PREVIEW_SIZE, - PROP_NAV_WINDOW_PER_DISPLAY, PROP_INFO_WINDOW_PER_DISPLAY, PROP_TRUST_DIRTY_FLAG, PROP_SAVE_DEVICE_STATUS, @@ -130,9 +129,6 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass) GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_NAV_PREVIEW_SIZE, "navigation-preview-size", GIMP_TYPE_PREVIEW_SIZE, GIMP_PREVIEW_SIZE_HUGE); - GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_NAV_WINDOW_PER_DISPLAY, - "navigation-window-per-display", - FALSE); GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY, "info-window-per-display", FALSE); @@ -218,9 +214,6 @@ gimp_gui_config_set_property (GObject *object, case PROP_NAV_PREVIEW_SIZE: gui_config->nav_preview_size = g_value_get_enum (value); break; - case PROP_NAV_WINDOW_PER_DISPLAY: - gui_config->nav_window_per_display = g_value_get_boolean (value); - break; case PROP_INFO_WINDOW_PER_DISPLAY: gui_config->info_window_per_display = g_value_get_boolean (value); break; @@ -299,9 +292,6 @@ gimp_gui_config_get_property (GObject *object, case PROP_NAV_PREVIEW_SIZE: g_value_set_enum (value, gui_config->nav_preview_size); break; - case PROP_NAV_WINDOW_PER_DISPLAY: - g_value_set_boolean (value, gui_config->nav_window_per_display); - break; case PROP_INFO_WINDOW_PER_DISPLAY: g_value_set_boolean (value, gui_config->info_window_per_display); break; diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h index 51596cf12a..d274cea88a 100644 --- a/app/config/gimpguiconfig.h +++ b/app/config/gimpguiconfig.h @@ -47,7 +47,6 @@ struct _GimpGuiConfig gboolean perfect_mouse; gint default_threshold; GimpPreviewSize nav_preview_size; - gboolean nav_window_per_display; gboolean info_window_per_display; gboolean trust_dirty_flag; gboolean save_device_status; diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 99a87a81e7..2948dc2369 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -41,7 +41,6 @@ #include "gimpdisplayshell-handlers.h" #include "gimprc.h" -#include "nav_window.h" #include "libgimp/gimpintl.h" diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c index 9a0b74ba54..fdc59a71b0 100644 --- a/app/dialogs/dialogs-constructors.c +++ b/app/dialogs/dialogs-constructors.c @@ -64,6 +64,7 @@ #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell-filter-dialog.h" +#include "display/gimpnavigationview.h" #include "about-dialog.h" #include "brushes-commands.h" @@ -126,6 +127,8 @@ static void dialogs_set_path_context_func (GimpDockable *dockable, GimpContext *context); static void dialogs_set_indexed_palette_context_func (GimpDockable *dockable, GimpContext *context); +static void dialogs_set_navigation_context_func (GimpDockable *dockable, + GimpContext *context); static GtkWidget * dialogs_dockable_new (GtkWidget *widget, const gchar *name, @@ -142,6 +145,9 @@ static void dialogs_path_view_image_changed (GimpContext *context, static void dialogs_indexed_palette_image_changed (GimpContext *context, GimpImage *gimage, GimpColormapEditor *editor); +static void dialogs_navigation_display_changed (GimpContext *context, + GimpDisplay *gdisp, + GimpNavigationView *view); /**********************/ @@ -900,6 +906,31 @@ dialogs_edit_palette_func (GimpData *data) } +/* display views */ + +GtkWidget * +dialogs_navigation_view_new (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size) +{ + GimpDisplay *gdisp; + GimpDisplayShell *shell = NULL; + GtkWidget *view; + + gdisp = gimp_context_get_display (context); + + if (gdisp) + shell = GIMP_DISPLAY_SHELL (gdisp->shell); + + view = gimp_navigation_view_new (shell); + + return dialogs_dockable_new (view, + _("Display Navigation"), _("Navigation"), + NULL, + dialogs_set_navigation_context_func); +} + + /* private functions */ static void @@ -1243,6 +1274,41 @@ dialogs_set_indexed_palette_context_func (GimpDockable *dockable, } } +static void +dialogs_set_navigation_context_func (GimpDockable *dockable, + GimpContext *context) +{ + GimpNavigationView *view; + + view = (GimpNavigationView *) g_object_get_data (G_OBJECT (dockable), + "gimp-dialogs-view"); + + if (view) + { + if (dockable->context) + { + g_signal_handlers_disconnect_by_func (G_OBJECT (dockable->context), + dialogs_navigation_display_changed, + view); + } + + if (context) + { + g_signal_connect (G_OBJECT (context), "display_changed", + G_CALLBACK (dialogs_navigation_display_changed), + view); + + dialogs_navigation_display_changed (context, + gimp_context_get_display (context), + view); + } + else + { + dialogs_navigation_display_changed (NULL, NULL, view); + } + } +} + static GtkWidget * dialogs_dockable_new (GtkWidget *widget, const gchar *name, @@ -1287,3 +1353,16 @@ dialogs_indexed_palette_image_changed (GimpContext *context, { gimp_colormap_editor_set_image (editor, gimage); } + +static void +dialogs_navigation_display_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); +} diff --git a/app/dialogs/dialogs-constructors.h b/app/dialogs/dialogs-constructors.h index 87cb12aa9e..c9e8379816 100644 --- a/app/dialogs/dialogs-constructors.h +++ b/app/dialogs/dialogs-constructors.h @@ -143,5 +143,9 @@ GtkWidget * dialogs_palette_editor_get (GimpDialogFactory *factory, gint preview_size); void dialogs_edit_palette_func (GimpData *data); +GtkWidget * dialogs_navigation_view_new (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size); + #endif /* __DIALOGS_CONSTRUCTORS_H__ */ diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c index ee3049fdc4..e4263b9bd3 100644 --- a/app/dialogs/dialogs.c +++ b/app/dialogs/dialogs.c @@ -79,7 +79,9 @@ static const GimpDialogFactoryEntry dock_entries[] = { "gimp-brush-editor", dialogs_brush_editor_get, 0, TRUE, FALSE, FALSE, TRUE }, { "gimp-gradient-editor", dialogs_gradient_editor_get, 0, TRUE, FALSE, FALSE, TRUE }, - { "gimp-palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE } + { "gimp-palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE }, + + { "gimp-navigation-view", dialogs_navigation_view_new, 0, FALSE, FALSE, FALSE, TRUE } }; diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index c73b5addf0..7e761db94c 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -172,7 +172,6 @@ static guint old_max_new_image_size; static GimpThumbnailSize old_thumbnail_size; static gboolean old_trust_dirty_flag; static gboolean old_use_help; -static gboolean old_nav_window_per_display; static gboolean old_info_window_follows_mouse; static gint old_help_browser; static gint old_cursor_mode; @@ -185,7 +184,6 @@ static gint edit_min_colors; static gboolean edit_install_cmap; static gboolean edit_cycled_marching_ants; static gint edit_last_opened_size; -static gboolean edit_nav_window_per_display; static gboolean edit_info_window_follows_mouse; static gboolean edit_disable_tearoff_menus; static gchar * edit_temp_path = NULL; @@ -368,7 +366,6 @@ prefs_check_settings (Gimp *gimp) edit_install_cmap != old_install_cmap || edit_cycled_marching_ants != old_cycled_marching_ants || edit_last_opened_size != old_last_opened_size || - edit_nav_window_per_display != old_nav_window_per_display || edit_info_window_follows_mouse != old_info_window_follows_mouse || edit_disable_tearoff_menus != old_disable_tearoff_menus || @@ -506,7 +503,6 @@ prefs_save_callback (GtkWidget *widget, gboolean save_install_cmap; gboolean save_cycled_marching_ants; gint save_last_opened_size; - gboolean save_nav_window_per_display; gboolean save_info_window_follows_mouse; gchar *save_temp_path; gchar *save_swap_path; @@ -557,7 +553,6 @@ prefs_save_callback (GtkWidget *widget, save_install_cmap = gimprc.install_cmap; save_cycled_marching_ants = gimprc.cycled_marching_ants; save_last_opened_size = gimprc.last_opened_size; - save_nav_window_per_display = gimprc.nav_window_per_display; save_info_window_follows_mouse = gimprc.info_window_follows_mouse; save_temp_path = base_config->temp_path; @@ -779,12 +774,6 @@ prefs_save_callback (GtkWidget *widget, gimprc.last_opened_size = edit_last_opened_size; update = g_list_append (update, "last-opened-size"); } - if (edit_nav_window_per_display != old_nav_window_per_display) - { - gimprc.nav_window_per_display = edit_nav_window_per_display; - update = g_list_append (update, "nav-window-per-display"); - remove = g_list_append (remove, "nav-window-follows-auto"); - } if (edit_info_window_follows_mouse != old_info_window_follows_mouse) { gimprc.info_window_follows_mouse = edit_info_window_follows_mouse; @@ -869,7 +858,6 @@ prefs_save_callback (GtkWidget *widget, gimprc.install_cmap = save_install_cmap; gimprc.cycled_marching_ants = save_cycled_marching_ants; gimprc.last_opened_size = save_last_opened_size; - gimprc.nav_window_per_display = save_nav_window_per_display; gimprc.info_window_follows_mouse = save_info_window_follows_mouse; base_config->temp_path = save_temp_path; @@ -952,7 +940,9 @@ prefs_cancel_callback (GtkWidget *widget, if (gimprc.nav_preview_size != old_nav_preview_size) { gimprc.nav_preview_size = old_nav_preview_size; +#if 0 gdisplays_nav_preview_resized (); +#endif } if ((gimprc.transparency_type != old_transparency_type) || (gimprc.transparency_size != old_transparency_size)) @@ -980,7 +970,6 @@ prefs_cancel_callback (GtkWidget *widget, edit_install_cmap = old_install_cmap; edit_cycled_marching_ants = old_cycled_marching_ants; edit_last_opened_size = old_last_opened_size; - edit_nav_window_per_display = old_nav_window_per_display; edit_info_window_follows_mouse = old_info_window_follows_mouse; edit_disable_tearoff_menus = old_disable_tearoff_menus; @@ -1041,7 +1030,6 @@ prefs_toggle_callback (GtkWidget *widget, data == &edit_stingy_memory_use || data == &edit_install_cmap || data == &edit_cycled_marching_ants || - data == &edit_nav_window_per_display || data == &edit_info_window_follows_mouse || data == &edit_disable_tearoff_menus) { @@ -1105,7 +1093,9 @@ prefs_nav_preview_size_callback (GtkWidget *widget, { gimp_menu_item_update (widget, data); +#if 0 gdisplays_nav_preview_resized (); +#endif } static void @@ -1643,7 +1633,6 @@ preferences_dialog_create (Gimp *gimp) edit_install_cmap = gimprc.install_cmap; edit_cycled_marching_ants = gimprc.cycled_marching_ants; edit_last_opened_size = gimprc.last_opened_size; - edit_nav_window_per_display = gimprc.nav_window_per_display; edit_info_window_follows_mouse = gimprc.info_window_follows_mouse; edit_disable_tearoff_menus = gimprc.disable_tearoff_menus; @@ -1718,7 +1707,6 @@ preferences_dialog_create (Gimp *gimp) old_install_cmap = edit_install_cmap; old_cycled_marching_ants = edit_cycled_marching_ants; old_last_opened_size = edit_last_opened_size; - old_nav_window_per_display = edit_nav_window_per_display; old_info_window_follows_mouse = edit_info_window_follows_mouse; old_disable_tearoff_menus = edit_disable_tearoff_menus; @@ -2102,8 +2090,6 @@ preferences_dialog_create (Gimp *gimp) /* Dialog Bahaviour */ vbox2 = prefs_frame_new (_("Dialog Behavior"), GTK_CONTAINER (vbox)); - prefs_check_button_new (_("Navigation Window per Display"), - &edit_nav_window_per_display, GTK_BOX (vbox2)); prefs_check_button_new (_("Info Window Follows Mouse"), &edit_info_window_follows_mouse, GTK_BOX (vbox2)); diff --git a/app/display/Makefile.am b/app/display/Makefile.am index f5e5b2d24b..1eca75e529 100644 --- a/app/display/Makefile.am +++ b/app/display/Makefile.am @@ -49,6 +49,8 @@ libappdisplay_a_sources = @STRIP_BEGIN@ \ gimpdisplayshell-scroll.h \ gimpdisplayshell-selection.c \ gimpdisplayshell-selection.h \ + gimpnavigationview.c \ + gimpnavigationview.h \ gimpprogress.c \ gimpprogress.h \ gimpstatusbar.c \ diff --git a/app/display/display-types.h b/app/display/display-types.h index 77e66e8336..f3dd87966c 100644 --- a/app/display/display-types.h +++ b/app/display/display-types.h @@ -26,13 +26,14 @@ #include "display/display-enums.h" -typedef struct _GimpDisplay GimpDisplay; /*< proxy-resume >*/ -typedef struct _GimpDisplayShell GimpDisplayShell; +typedef struct _GimpDisplay GimpDisplay; /*< proxy-resume >*/ +typedef struct _GimpDisplayShell GimpDisplayShell; -typedef struct _GimpStatusbar GimpStatusbar; /*< proxy-skip >*/ +typedef struct _GimpNavigationView GimpNavigationView; /*< proxy-skip >*/ +typedef struct _GimpStatusbar GimpStatusbar; -typedef struct _NavigationDialog NavigationDialog; -typedef struct _Selection Selection; +typedef struct _NavigationDialog NavigationDialog; +typedef struct _Selection Selection; #endif /* __DISPLAY_TYPES_H__ */ diff --git a/app/display/gimpdisplay-foreach.c b/app/display/gimpdisplay-foreach.c index cc03cabaa9..cb0a83bedd 100644 --- a/app/display/gimpdisplay-foreach.c +++ b/app/display/gimpdisplay-foreach.c @@ -28,8 +28,6 @@ #include "gimpdisplay-foreach.h" #include "gimpdisplayshell.h" -#include "nav_window.h" - void gdisplays_foreach (GFunc func, @@ -52,27 +50,6 @@ gdisplays_expose_full (void) } } -void -gdisplays_nav_preview_resized (void) -{ - GimpDisplayShell *shell; - GSList *list; - - for (list = display_list; list; list = g_slist_next (list)) - { - shell = GIMP_DISPLAY_SHELL (GIMP_DISPLAY (list->data)->shell); - - if (shell->nav_dialog) - nav_dialog_preview_resized (shell->nav_dialog); - - if (shell->nav_popup) - { - nav_dialog_free (NULL, shell->nav_popup); - shell->nav_popup = NULL; - } - } -} - gboolean gdisplays_dirty (void) { diff --git a/app/display/gimpdisplay-foreach.h b/app/display/gimpdisplay-foreach.h index d7a355c95c..4cb7d2b3d1 100644 --- a/app/display/gimpdisplay-foreach.h +++ b/app/display/gimpdisplay-foreach.h @@ -31,7 +31,6 @@ gboolean gdisplays_dirty (void); void gdisplays_delete (void); void gdisplays_flush (void); void gdisplays_finish_draw (void); -void gdisplays_nav_preview_resized (void); void gdisplays_set_busy (void); void gdisplays_unset_busy (void); diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 99a87a81e7..2948dc2369 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -41,7 +41,6 @@ #include "gimpdisplayshell-handlers.h" #include "gimprc.h" -#include "nav_window.h" #include "libgimp/gimpintl.h" diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 15187c354e..22c7732c74 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -57,10 +57,10 @@ #include "gimpdisplayshell-scale.h" #include "gimpdisplayshell-scroll.h" #include "gimpdisplayshell-selection.h" +#include "gimpnavigationview.h" #include "gimpstatusbar.h" #include "gimprc.h" -#include "nav_window.h" #include "libgimp/gimpintl.h" @@ -1241,7 +1241,7 @@ gimp_display_shell_nav_button_press (GtkWidget *widget, { if ((bevent->type == GDK_BUTTON_PRESS) && (bevent->button == 1)) { - nav_dialog_create_popup (shell, widget, bevent->x, bevent->y); + gimp_navigation_view_popup (shell, widget, bevent->x, bevent->y); } return TRUE; diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index 21de10506e..fe45c8cacc 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -41,6 +41,7 @@ #include "core/gimpimage-new.h" #include "core/gimplayer.h" #include "core/gimplayermask.h" +#include "core/gimpmarshal.h" #include "core/gimppattern.h" #include "file/file-utils.h" @@ -70,7 +71,6 @@ #include "gimpstatusbar.h" #include "gimprc.h" -#include "nav_window.h" #include "undo.h" #include "libgimp/gimpintl.h" @@ -78,6 +78,13 @@ #define MAX_TITLE_BUF 256 +enum +{ + SCALED, + SCROLLED, + LAST_SIGNAL +}; + /* local function prototypes */ @@ -114,6 +121,8 @@ static void gimp_display_shell_close_warning_callback (GtkWidget *widget gpointer data); +static guint display_shell_signals[LAST_SIGNAL] = { 0 }; + static GtkWindowClass *parent_class = NULL; @@ -167,6 +176,24 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass) parent_class = g_type_class_peek_parent (klass); + display_shell_signals[SCALED] = + g_signal_new ("scaled", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GimpDisplayShellClass, scaled), + NULL, NULL, + gimp_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + display_shell_signals[SCROLLED] = + g_signal_new ("scrolled", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GimpDisplayShellClass, scrolled), + NULL, NULL, + gimp_marshal_VOID__VOID, + G_TYPE_NONE, 0); + object_class->destroy = gimp_display_shell_destroy; widget_class->delete_event = gimp_display_shell_delete_event; @@ -234,7 +261,6 @@ gimp_display_shell_init (GimpDisplayShell *shell) shell->warning_dialog = NULL; shell->info_dialog = NULL; - shell->nav_dialog = NULL; shell->nav_popup = NULL; shell->filters = NULL; @@ -336,15 +362,9 @@ gimp_display_shell_destroy (GtkObject *object) shell->info_dialog = NULL; } - /* free the nav_dialog unconditionally because nav_dialog_free(shell,NULL) - * acts as notification for the global nav dialog - */ - nav_dialog_free (shell, shell->nav_dialog); - shell->nav_dialog = NULL; - if (shell->nav_popup) { - nav_dialog_free (shell, shell->nav_popup); + gtk_widget_destroy (shell->nav_popup); shell->nav_popup = NULL; } @@ -784,6 +804,22 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell) gimp_display_shell_shrink_wrap (shell); } +void +gimp_display_shell_scaled (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + g_signal_emit (G_OBJECT (shell), display_shell_signals[SCALED], 0); +} + +void +gimp_display_shell_scrolled (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + g_signal_emit (G_OBJECT (shell), display_shell_signals[SCROLLED], 0); +} + void gimp_display_shell_transform_coords (GimpDisplayShell *shell, GimpCoords *image_coords, diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h index 6d31f2f89e..c9c0a14a82 100644 --- a/app/display/gimpdisplayshell-draw.h +++ b/app/display/gimpdisplayshell-draw.h @@ -99,8 +99,7 @@ struct _GimpDisplayShell GtkWidget *warning_dialog; /* close warning dialog */ InfoDialog *info_dialog; /* image information dialog */ - NavigationDialog *nav_dialog; /* image navigation dialog */ - NavigationDialog *nav_popup; /* navigation popup */ + GtkWidget *nav_popup; /* navigation popup */ GList *filters; /* color display conversion stuff */ GtkWidget *filters_dialog; /* color display filter dialog */ @@ -109,6 +108,9 @@ struct _GimpDisplayShell struct _GimpDisplayShellClass { GtkWindowClass parent_class; + + void (* scaled) (GimpDisplayShell *shell); + void (* scrolled) (GimpDisplayShell *shell); }; @@ -121,6 +123,9 @@ void gimp_display_shell_close (GimpDisplayShell *shell, void gimp_display_shell_reconnect (GimpDisplayShell *shell); +void gimp_display_shell_scaled (GimpDisplayShell *shell); +void gimp_display_shell_scrolled (GimpDisplayShell *shell); + void gimp_display_shell_transform_coords (GimpDisplayShell *shell, GimpCoords *image_coords, GimpCoords *display_coords); diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index 0c3b44461e..057157ae58 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -40,7 +40,6 @@ #include "gimpstatusbar.h" #include "gimprc.h" -#include "nav_window.h" /* local function prototypes */ @@ -150,10 +149,7 @@ gimp_display_shell_scale_setup (GimpDisplayShell *shell) gtk_widget_queue_draw (GTK_WIDGET (hruler)); gtk_widget_queue_draw (GTK_WIDGET (vruler)); - nav_dialog_update (shell->nav_dialog); - - if (shell->nav_popup) - nav_dialog_update (shell->nav_popup); + gimp_display_shell_scaled (shell); #if 0 g_print ("offset_x: %d\n" diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c index 6a15796d86..39f9b4272d 100644 --- a/app/display/gimpdisplayshell-scroll.c +++ b/app/display/gimpdisplayshell-scroll.c @@ -37,7 +37,6 @@ #include "gimpdisplayshell-scroll.h" #include "gimprc.h" -#include "nav_window.h" gboolean @@ -127,10 +126,7 @@ gimp_display_shell_scroll (GimpDisplayShell *shell, gimp_display_flush (shell->gdisp); } - nav_dialog_update (shell->nav_dialog); - - if (shell->nav_popup) - nav_dialog_update (shell->nav_popup); + gimp_display_shell_scrolled (shell); /* Make sure graphics expose events are processed before scrolling * again diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 21de10506e..fe45c8cacc 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -41,6 +41,7 @@ #include "core/gimpimage-new.h" #include "core/gimplayer.h" #include "core/gimplayermask.h" +#include "core/gimpmarshal.h" #include "core/gimppattern.h" #include "file/file-utils.h" @@ -70,7 +71,6 @@ #include "gimpstatusbar.h" #include "gimprc.h" -#include "nav_window.h" #include "undo.h" #include "libgimp/gimpintl.h" @@ -78,6 +78,13 @@ #define MAX_TITLE_BUF 256 +enum +{ + SCALED, + SCROLLED, + LAST_SIGNAL +}; + /* local function prototypes */ @@ -114,6 +121,8 @@ static void gimp_display_shell_close_warning_callback (GtkWidget *widget gpointer data); +static guint display_shell_signals[LAST_SIGNAL] = { 0 }; + static GtkWindowClass *parent_class = NULL; @@ -167,6 +176,24 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass) parent_class = g_type_class_peek_parent (klass); + display_shell_signals[SCALED] = + g_signal_new ("scaled", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GimpDisplayShellClass, scaled), + NULL, NULL, + gimp_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + display_shell_signals[SCROLLED] = + g_signal_new ("scrolled", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GimpDisplayShellClass, scrolled), + NULL, NULL, + gimp_marshal_VOID__VOID, + G_TYPE_NONE, 0); + object_class->destroy = gimp_display_shell_destroy; widget_class->delete_event = gimp_display_shell_delete_event; @@ -234,7 +261,6 @@ gimp_display_shell_init (GimpDisplayShell *shell) shell->warning_dialog = NULL; shell->info_dialog = NULL; - shell->nav_dialog = NULL; shell->nav_popup = NULL; shell->filters = NULL; @@ -336,15 +362,9 @@ gimp_display_shell_destroy (GtkObject *object) shell->info_dialog = NULL; } - /* free the nav_dialog unconditionally because nav_dialog_free(shell,NULL) - * acts as notification for the global nav dialog - */ - nav_dialog_free (shell, shell->nav_dialog); - shell->nav_dialog = NULL; - if (shell->nav_popup) { - nav_dialog_free (shell, shell->nav_popup); + gtk_widget_destroy (shell->nav_popup); shell->nav_popup = NULL; } @@ -784,6 +804,22 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell) gimp_display_shell_shrink_wrap (shell); } +void +gimp_display_shell_scaled (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + g_signal_emit (G_OBJECT (shell), display_shell_signals[SCALED], 0); +} + +void +gimp_display_shell_scrolled (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + g_signal_emit (G_OBJECT (shell), display_shell_signals[SCROLLED], 0); +} + void gimp_display_shell_transform_coords (GimpDisplayShell *shell, GimpCoords *image_coords, diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index 6d31f2f89e..c9c0a14a82 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -99,8 +99,7 @@ struct _GimpDisplayShell GtkWidget *warning_dialog; /* close warning dialog */ InfoDialog *info_dialog; /* image information dialog */ - NavigationDialog *nav_dialog; /* image navigation dialog */ - NavigationDialog *nav_popup; /* navigation popup */ + GtkWidget *nav_popup; /* navigation popup */ GList *filters; /* color display conversion stuff */ GtkWidget *filters_dialog; /* color display filter dialog */ @@ -109,6 +108,9 @@ struct _GimpDisplayShell struct _GimpDisplayShellClass { GtkWindowClass parent_class; + + void (* scaled) (GimpDisplayShell *shell); + void (* scrolled) (GimpDisplayShell *shell); }; @@ -121,6 +123,9 @@ void gimp_display_shell_close (GimpDisplayShell *shell, void gimp_display_shell_reconnect (GimpDisplayShell *shell); +void gimp_display_shell_scaled (GimpDisplayShell *shell); +void gimp_display_shell_scrolled (GimpDisplayShell *shell); + void gimp_display_shell_transform_coords (GimpDisplayShell *shell, GimpCoords *image_coords, GimpCoords *display_coords); diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c index 9301a18b97..4a27097f32 100644 --- a/app/display/gimpnavigationeditor.c +++ b/app/display/gimpnavigationeditor.c @@ -1,6 +1,12 @@ /* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * + * gimpnavigationview.c + * Copyright (C) 2001 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas + * * 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 @@ -18,140 +24,126 @@ #include "config.h" -#include - #include -#include -#include "libgimpmath/gimpmath.h" #include "libgimpwidgets/gimpwidgets.h" -#include "widgets/widgets-types.h" - -#include "base/temp-buf.h" +#include "display-types.h" #include "core/gimp.h" -#include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" -#include "core/gimplist.h" - -#include "file/file-utils.h" - -#include "display/gimpdisplay.h" -#include "display/gimpdisplay-foreach.h" -#include "display/gimpdisplayshell.h" -#include "display/gimpdisplayshell-scroll.h" -#include "display/gimpdisplayshell-scale.h" #include "widgets/gimpnavigationpreview.h" -#include "app_procs.h" +#include "gimpdisplay.h" +#include "gimpdisplayshell.h" +#include "gimpdisplayshell-scale.h" +#include "gimpdisplayshell-scroll.h" +#include "gimpnavigationview.h" + #include "gimprc.h" -#include "nav_window.h" #include "libgimp/gimpintl.h" -#define BORDER_PEN_WIDTH 3 -#define MAX_SCALE_BUF 20 +#define MAX_SCALE_BUF 20 -struct _NavigationDialog +static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass); +static void gimp_navigation_view_init (GimpNavigationView *view); + +static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell, + gboolean popup); + +static gboolean gimp_navigation_view_button_release (GtkWidget *widget, + GdkEventButton *bevent, + GimpDisplayShell *shell); +static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview, + gint x, + gint 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_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_update_marker (GimpNavigationView *view); + + +static GimpEditorClass *parent_class = NULL; + + +GType +gimp_navigation_view_get_type (void) { - GtkWidget *shell; + static GType view_type = 0; - GtkWidget *preview; + if (! view_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, + }; - GtkWidget *zoom_label; - GtkObject *zoom_adjustment; - GimpDisplayShell *disp_shell; + view_type = g_type_register_static (GIMP_TYPE_EDITOR, + "GimpNavigationView", + &view_info, 0); + } - gboolean block_adj_sig; - gboolean frozen; -}; + return view_type; +} - -static NavigationDialog * nav_dialog_new (GimpDisplayShell *shell); - -static gchar * nav_dialog_title (GimpDisplayShell *shell); -static GtkWidget * nav_dialog_create_preview (NavigationDialog *nav_dialog, - GimpImage *gimage); -static void nav_dialog_update_marker (NavigationDialog *nav_dialog); -static void nav_dialog_close_callback (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_marker_changed (GimpNavigationPreview *preview, - gint x, - gint y, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom (GimpNavigationPreview *preview, - GimpZoomType direction, - NavigationDialog *nav_dialog); -static void nav_dialog_scroll (GimpNavigationPreview *preview, - GdkScrollDirection direction, - NavigationDialog *nav_dialog); -static gboolean nav_dialog_button_release (GtkWidget *widget, - GdkEventButton *bevent, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_in (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_out (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_adj_changed (GtkAdjustment *adj, - NavigationDialog *nav_dialog); -static void nav_dialog_display_changed (GimpContext *context, - GimpDisplay *gdisp, - NavigationDialog *nav_dialog); - - -static NavigationDialog *nav_window_auto = NULL; - - -/* public functions */ - -NavigationDialog * -nav_dialog_create (GimpDisplayShell *shell) +static void +gimp_navigation_view_class_init (GimpNavigationViewClass *klass) { - NavigationDialog *nav_dialog; - GtkWidget *abox; - GtkWidget *frame; - GtkWidget *hbox; - GtkWidget *button; - GtkWidget *image; - GtkWidget *hscale; - gchar *title; - gchar scale_str[MAX_SCALE_BUF]; + GObjectClass *object_class; - title = nav_dialog_title (shell); + object_class = G_OBJECT_CLASS (klass); - nav_dialog = nav_dialog_new (shell); + parent_class = g_type_class_peek_parent (klass); +} - nav_dialog->shell = gimp_dialog_new (title, "navigation_dialog", - gimp_standard_help_func, - "dialogs/navigation_window.html", - GTK_WIN_POS_MOUSE, - FALSE, TRUE, TRUE, +static void +gimp_navigation_view_init (GimpNavigationView *view) +{ + GtkWidget *abox; + GtkWidget *frame; - "_delete_event_", - nav_dialog_close_callback, - nav_dialog, NULL, NULL, TRUE, TRUE, - - NULL); - - g_free (title); - - gtk_dialog_set_has_separator (GTK_DIALOG (nav_dialog->shell), FALSE); - gtk_widget_hide (GTK_DIALOG (nav_dialog->shell)->action_area); - - g_object_weak_ref (G_OBJECT (nav_dialog->shell), - (GWeakNotify) g_free, - nav_dialog); + view->shell = NULL; /* the 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_box_pack_start (GTK_BOX (view), abox, TRUE, TRUE, 0); gtk_widget_show (abox); frame = gtk_frame_new (NULL); @@ -159,128 +151,119 @@ nav_dialog_create (GimpDisplayShell *shell) gtk_container_add (GTK_CONTAINER (abox), frame); gtk_widget_show (frame); - nav_dialog->preview = nav_dialog_create_preview (nav_dialog, - shell->gdisp->gimage); - gtk_container_add (GTK_CONTAINER (frame), nav_dialog->preview); - gtk_widget_show (nav_dialog->preview); + view->preview = gimp_navigation_preview_new (NULL, gimprc.nav_preview_size); + gtk_container_add (GTK_CONTAINER (frame), view->preview); + gtk_widget_show (view->preview); - nav_dialog_update_marker (nav_dialog); + g_signal_connect (G_OBJECT (view->preview), "marker_changed", + G_CALLBACK (gimp_navigation_view_marker_changed), + view); + g_signal_connect (G_OBJECT (view->preview), "zoom", + G_CALLBACK (gimp_navigation_view_zoom), + view); + g_signal_connect (G_OBJECT (view->preview), "scroll", + G_CALLBACK (gimp_navigation_view_scroll), + view); - /* the zoom scale */ + gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE); +} - nav_dialog->zoom_adjustment = - gtk_adjustment_new (0.0, -15.0, 16.0, 1.0, 1.0, 1.0); - g_signal_connect (G_OBJECT (nav_dialog->zoom_adjustment), "value_changed", - G_CALLBACK (nav_dialog_zoom_adj_changed), - nav_dialog); +/* public functions */ - 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_end (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), hscale, - FALSE, FALSE, 0); - gtk_widget_show (hscale); - - /* the zoom buttons */ - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), hbox, - FALSE, FALSE, 0); - gtk_widget_show (hbox); - - button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - 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); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (nav_dialog_zoom_out), - nav_dialog); - - /* user zoom ratio */ - g_snprintf (scale_str, sizeof (scale_str), "%d:%d", - SCALEDEST (nav_dialog->disp_shell->gdisp), - SCALESRC (nav_dialog->disp_shell->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); - - button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - 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); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (nav_dialog_zoom_in), - nav_dialog); - - return nav_dialog; +GtkWidget * +gimp_navigation_view_new (GimpDisplayShell *shell) +{ + return gimp_navigation_view_new_private (shell, FALSE); } void -nav_dialog_create_popup (GimpDisplayShell *shell, - GtkWidget *widget, - gint button_x, - gint button_y) +gimp_navigation_view_set_shell (GimpNavigationView *view, + GimpDisplayShell *shell) { - NavigationDialog *nav_dialog; + 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 (G_OBJECT (view->shell), + gimp_navigation_view_shell_scaled, + view); + g_signal_handlers_disconnect_by_func (G_OBJECT (view->shell), + gimp_navigation_view_shell_scrolled, + view); + } + else if (shell) + { + gtk_widget_set_sensitive (GTK_WIDGET (view), TRUE); + } + + view->shell = shell; + + if (view->shell) + { + gimp_preview_set_viewable (GIMP_PREVIEW (view->preview), + GIMP_VIEWABLE (shell->gdisp->gimage)); + + g_signal_connect (G_OBJECT (view->shell), "scaled", + G_CALLBACK (gimp_navigation_view_shell_scaled), + view); + g_signal_connect (G_OBJECT (view->shell), "scrolled", + G_CALLBACK (gimp_navigation_view_shell_scrolled), + view); + + gimp_navigation_view_shell_scaled (view->shell, view); + } + else + { + gimp_preview_set_viewable (GIMP_PREVIEW (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; gint x, y; gint x_org, y_org; gint scr_w, scr_h; + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + g_return_if_fail (GTK_IS_WIDGET (widget)); + if (! shell->nav_popup) { GtkWidget *frame; - GtkWidget *preview_frame; - shell->nav_popup = nav_dialog = nav_dialog_new (shell); - - nav_dialog->shell = gtk_window_new (GTK_WINDOW_POPUP); - - g_object_weak_ref (G_OBJECT (nav_dialog->shell), - (GWeakNotify) g_free, - nav_dialog); + 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 (nav_dialog->shell), frame); + gtk_container_add (GTK_CONTAINER (shell->nav_popup), frame); gtk_widget_show (frame); - preview_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (preview_frame), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (frame), preview_frame); - gtk_widget_show (preview_frame); + view = GIMP_NAVIGATION_VIEW (gimp_navigation_view_new_private (shell, TRUE)); + gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view)); + gtk_widget_show (GTK_WIDGET (view)); - nav_dialog->preview = nav_dialog_create_preview (nav_dialog, - shell->gdisp->gimage); - gtk_container_add (GTK_CONTAINER (preview_frame), nav_dialog->preview); - gtk_widget_show (nav_dialog->preview); - - g_signal_connect (G_OBJECT (nav_dialog->preview), "button_release_event", - G_CALLBACK (nav_dialog_button_release), - nav_dialog); + g_signal_connect (G_OBJECT (view->preview), "button_release_event", + G_CALLBACK (gimp_navigation_view_button_release), + shell); } else { - nav_dialog = shell->nav_popup; - - gtk_widget_hide (nav_dialog->shell); + view = GIMP_NAVIGATION_VIEW (GTK_BIN (GTK_BIN (shell->nav_popup)->child)->child);; } - nav_dialog_update_marker (nav_dialog); - - preview = GIMP_NAVIGATION_PREVIEW (nav_dialog->preview); + preview = GIMP_NAVIGATION_PREVIEW (view->preview); /* decide where to put the popup */ gdk_window_get_origin (widget->window, &x_org, &y_org); @@ -288,13 +271,16 @@ nav_dialog_create_popup (GimpDisplayShell *shell, scr_w = gdk_screen_width (); scr_h = gdk_screen_height (); - x = (x_org + button_x - - preview->p_x - - ((preview->p_width - BORDER_PEN_WIDTH + 1) * 0.5) - 2); +#define BORDER_WIDTH (2 * widget->style->xthickness) +#define BORDER_HEIGHT (2 * widget->style->ythickness) - y = (y_org + button_y - + x = (x_org + click_x - + preview->p_x - + ((preview->p_width - BORDER_WIDTH) * 0.5) - 2); + + y = (y_org + click_y - preview->p_y - - ((preview->p_height - BORDER_PEN_WIDTH + 1) * 0.5) - 2); + ((preview->p_height - BORDER_HEIGHT) * 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 @@ -310,436 +296,336 @@ nav_dialog_create_popup (GimpDisplayShell *shell, x = (x + preview->p_width > scr_w) ? scr_w - preview->p_width - 2 : x; y = (y + preview->p_height > scr_h) ? scr_h - preview->p_height - 2 : y; - gtk_window_move (GTK_WINDOW (nav_dialog->shell), x, y); - gtk_widget_show (nav_dialog->shell); + 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 = - (preview->p_width - BORDER_PEN_WIDTH + 1) * 0.5; + preview->motion_offset_x = (preview->p_width - BORDER_WIDTH) * 0.5; + preview->motion_offset_y = (preview->p_height - BORDER_HEIGHT) * 0.5; - preview->motion_offset_y = - (preview->p_height - BORDER_PEN_WIDTH + 1) * 0.5; +#undef BORDER_WIDTH +#undef BORDER_HEIGHT gimp_navigation_preview_grab_pointer (preview); } -void -nav_dialog_free (GimpDisplayShell *del_shell, - NavigationDialog *nav_dialog) -{ - /* So this functions works both ways.. - * it will come in here with nav_dialog == null - * if the auto mode is on... - */ - - if (nav_dialog) - { - gtk_widget_destroy (nav_dialog->shell); - } - else if (nav_window_auto) - { - GimpDisplay *gdisp = NULL; - GList *list; - - /* Only freeze if we are displaying the image we have deleted */ - if (nav_window_auto->disp_shell != del_shell) - return; - - for (list = GIMP_LIST (the_gimp->images)->list; - list; - list = g_list_next (list)) - { - gdisp = gdisplays_check_valid (NULL, GIMP_IMAGE (list->data)); - - if (gdisp) - break; - } - - if (gdisp) - { - nav_dialog_display_changed (NULL, gdisp, nav_window_auto); - } - else - { - /* Clear window and freeze */ - nav_window_auto->frozen = TRUE; - gtk_window_set_title (GTK_WINDOW (nav_window_auto->shell), - _("Navigation: No Image")); - - gtk_widget_set_sensitive (nav_window_auto->shell, FALSE); - nav_window_auto->disp_shell = NULL; - gtk_widget_hide (GTK_WIDGET (nav_window_auto->shell)); - } - } -} - -void -nav_dialog_show (NavigationDialog *nav_dialog) -{ - g_return_if_fail (nav_dialog != NULL); - - if (! GTK_WIDGET_VISIBLE (nav_dialog->shell)) - { - gtk_widget_show (nav_dialog->shell); - } - else - { - gdk_window_raise (nav_dialog->shell->window); - } -} - -void -nav_dialog_show_auto (Gimp *gimp) -{ - GimpContext *context; - GimpDisplay *gdisp; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - - context = gimp_get_user_context (gimp); - - gdisp = gimp_context_get_display (context); - - if (! gdisp) - return; - - if (! nav_window_auto) - { - nav_window_auto = nav_dialog_create (GIMP_DISPLAY_SHELL (gdisp->shell)); - - g_signal_connect (G_OBJECT (context), "display_changed", - G_CALLBACK (nav_dialog_display_changed), - nav_window_auto); - } - - nav_dialog_show (nav_window_auto); - - gtk_widget_set_sensitive (nav_window_auto->shell, TRUE); - - nav_window_auto->frozen = FALSE; -} - -void -nav_dialog_update (NavigationDialog *nav_dialog) -{ - /* So this functions works both ways.. - * it will come in here with info_win == null - * if the auto mode is on... - */ - - if (! nav_dialog) - { - if (nav_window_auto && ! nav_window_auto->frozen) - { - nav_dialog_update (nav_window_auto); - } - - return; - } - - if (! GTK_WIDGET_VISIBLE (nav_dialog->shell)) - return; - - if (nav_dialog->zoom_label) - { - gchar scale_str[MAX_SCALE_BUF]; - - /* Update the zoom scale string */ - g_snprintf (scale_str, sizeof (scale_str), "%d:%d", - SCALEDEST (nav_dialog->disp_shell->gdisp), - SCALESRC (nav_dialog->disp_shell->gdisp)); - - gtk_label_set_text (GTK_LABEL (nav_dialog->zoom_label), scale_str); - } - - if (nav_dialog->zoom_adjustment) - { - GtkAdjustment *adj; - gdouble f; - gdouble val; - - adj = GTK_ADJUSTMENT (nav_dialog->zoom_adjustment); - - f = (((gdouble) SCALEDEST (nav_dialog->disp_shell->gdisp)) / - ((gdouble) SCALESRC (nav_dialog->disp_shell->gdisp))); - - if (f < 1.0) - val = -1.0 / f; - else - val = f; - - if (abs ((gint) adj->value) != (gint) (val - 1) && - ! nav_dialog->block_adj_sig) - { - adj->value = val; - - gtk_adjustment_changed (GTK_ADJUSTMENT (nav_dialog->zoom_adjustment)); - } - } - - nav_dialog_update_marker (nav_dialog); -} - -void -nav_dialog_preview_resized (NavigationDialog *nav_dialog) -{ - if (! nav_dialog) - return; -} - /* private functions */ -static NavigationDialog * -nav_dialog_new (GimpDisplayShell *shell) -{ - NavigationDialog *nav_dialog; - - nav_dialog = g_new0 (NavigationDialog, 1); - - nav_dialog->shell = NULL; - nav_dialog->preview = NULL; - nav_dialog->zoom_label = NULL; - nav_dialog->zoom_adjustment = NULL; - nav_dialog->disp_shell = shell; - - nav_dialog->block_adj_sig = FALSE; - nav_dialog->frozen = FALSE; - - return nav_dialog; -} - -static gchar * -nav_dialog_title (GimpDisplayShell *shell) -{ - gchar *basename; - gchar *title; - - basename = file_utils_uri_to_utf8_basename (gimp_image_get_uri (shell->gdisp->gimage)); - - title = g_strdup_printf (_("Navigation: %s-%d.%d"), - basename, - gimp_image_get_ID (shell->gdisp->gimage), - shell->gdisp->instance); - - g_free (basename); - - return title; -} - static GtkWidget * -nav_dialog_create_preview (NavigationDialog *nav_dialog, - GimpImage *gimage) +gimp_navigation_view_new_private (GimpDisplayShell *shell, + gboolean popup) { - GtkWidget *preview; + GimpNavigationView *view; - preview = gimp_navigation_preview_new (gimage, gimprc.nav_preview_size); + g_return_val_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell), NULL); - g_signal_connect (G_OBJECT (preview), "marker_changed", - G_CALLBACK (nav_dialog_marker_changed), - nav_dialog); - 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); + view = g_object_new (GIMP_TYPE_NAVIGATION_VIEW, NULL); - return preview; -} - -static void -nav_dialog_update_marker (NavigationDialog *nav_dialog) -{ - GimpImage *gimage; - gdouble xratio; - gdouble yratio; /* Screen res ratio */ - - /* Calculate preview size */ - gimage = nav_dialog->disp_shell->gdisp->gimage; - - xratio = SCALEFACTOR_X (nav_dialog->disp_shell->gdisp); - yratio = SCALEFACTOR_Y (nav_dialog->disp_shell->gdisp); - - if (GIMP_PREVIEW (nav_dialog->preview)->dot_for_dot != - nav_dialog->disp_shell->gdisp->dot_for_dot) - gimp_preview_set_dot_for_dot (GIMP_PREVIEW (nav_dialog->preview), - nav_dialog->disp_shell->gdisp->dot_for_dot); - - gimp_navigation_preview_set_marker - (GIMP_NAVIGATION_PREVIEW (nav_dialog->preview), - RINT (nav_dialog->disp_shell->offset_x / xratio), - RINT (nav_dialog->disp_shell->offset_y / yratio), - RINT (nav_dialog->disp_shell->disp_width / xratio), - RINT (nav_dialog->disp_shell->disp_height / yratio)); -} - -static void -nav_dialog_close_callback (GtkWidget *widget, - NavigationDialog *nav_dialog) -{ - gtk_widget_hide (nav_dialog->shell); -} - -static void -nav_dialog_marker_changed (GimpNavigationPreview *nav_preview, - gint x, - gint y, - NavigationDialog *nav_dialog) -{ - gdouble xratio; - gdouble yratio; - gint xoffset; - gint yoffset; - - xratio = SCALEFACTOR_X (nav_dialog->disp_shell->gdisp); - yratio = SCALEFACTOR_Y (nav_dialog->disp_shell->gdisp); - - xoffset = x * xratio - nav_dialog->disp_shell->offset_x; - yoffset = y * yratio - nav_dialog->disp_shell->offset_y; - - gimp_display_shell_scroll (nav_dialog->disp_shell, xoffset, yoffset); -} - -static void -nav_dialog_zoom (GimpNavigationPreview *nav_preview, - GimpZoomType direction, - NavigationDialog *nav_dialog) -{ - gimp_display_shell_scale (nav_dialog->disp_shell, direction); -} - -static void -nav_dialog_scroll (GimpNavigationPreview *nav_preview, - GdkScrollDirection direction, - NavigationDialog *nav_dialog) -{ - GtkAdjustment *adj = NULL; - gdouble value; - - switch (direction) + if (! popup) { - case GDK_SCROLL_LEFT: - case GDK_SCROLL_RIGHT: - adj = nav_dialog->disp_shell->hsbdata; - break; + GtkWidget *hscale; - case GDK_SCROLL_UP: - case GDK_SCROLL_DOWN: - adj = nav_dialog->disp_shell->vsbdata; - break; + /* the editor buttons */ + + view->zoom_out_button = + gimp_editor_add_button (GIMP_EDITOR (view), + GTK_STOCK_ZOOM_OUT, + _("Zoom out"), NULL, + 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"), NULL, + 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"), NULL, + G_CALLBACK (gimp_navigation_view_zoom_100_clicked), + NULL, + view); + + view->zoom_fit_button = + gimp_editor_add_button (GIMP_EDITOR (view), + GTK_STOCK_ZOOM_FIT, + _("Zoom to fit window"), NULL, + G_CALLBACK (gimp_navigation_view_zoom_fit_clicked), + NULL, + view); + + view->shrink_wrap_button = + gimp_editor_add_button (GIMP_EDITOR (view), + GTK_STOCK_ZOOM_FIT, + _("Shrink Wrap"), NULL, + G_CALLBACK (gimp_navigation_view_shrink_clicked), + NULL, + view); + + /* the zoom scale */ + + view->zoom_adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -15.0, 15.0, 1.0, 1.0, 0.0)); + + g_signal_connect (G_OBJECT (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), 0); + gtk_box_pack_end (GTK_BOX (view), hscale, FALSE, FALSE, 0); + gtk_widget_show (hscale); + + /* the zoom label */ + + view->zoom_label = gtk_label_new ("1:1"); + gtk_box_pack_end (GTK_BOX (view), view->zoom_label, FALSE, FALSE, 0); + gtk_widget_show (view->zoom_label); } - g_assert (adj != NULL); + if (shell) + gimp_navigation_view_set_shell (view, shell); - 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); + return GTK_WIDGET (view); } static gboolean -nav_dialog_button_release (GtkWidget *widget, - GdkEventButton *bevent, - NavigationDialog *nav_dialog) +gimp_navigation_view_button_release (GtkWidget *widget, + GdkEventButton *bevent, + GimpDisplayShell *shell) { if (bevent->button == 1) { - gtk_widget_hide (nav_dialog->shell); + gtk_widget_hide (shell->nav_popup); } return FALSE; } static void -nav_dialog_zoom_in (GtkWidget *widget, - NavigationDialog *nav_dialog) +gimp_navigation_view_marker_changed (GimpNavigationPreview *preview, + gint x, + gint y, + GimpNavigationView *view) { - gimp_display_shell_scale (nav_dialog->disp_shell, GIMP_ZOOM_IN); + if (view->shell) + { + gdouble xratio; + gdouble yratio; + gint xoffset; + gint yoffset; + + xratio = SCALEFACTOR_X (view->shell->gdisp); + yratio = SCALEFACTOR_Y (view->shell->gdisp); + + xoffset = x * xratio - view->shell->offset_x; + yoffset = y * yratio - view->shell->offset_y; + + gimp_display_shell_scroll (view->shell, xoffset, yoffset); + } } static void -nav_dialog_zoom_out (GtkWidget *widget, - NavigationDialog *nav_dialog) +gimp_navigation_view_zoom (GimpNavigationPreview *preview, + GimpZoomType direction, + GimpNavigationView *view) { - gimp_display_shell_scale (nav_dialog->disp_shell, GIMP_ZOOM_OUT); + if (view->shell) + { + gimp_display_shell_scale (view->shell, direction); + } } static void -nav_dialog_zoom_adj_changed (GtkAdjustment *adj, - NavigationDialog *nav_dialog) +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) +{ + gint value; gint scalesrc; gint scaledest; - if (adj->value < 0.0) + value = RINT (adj->value); + + if (value < 0) { - scalesrc = abs ((gint) adj->value - 1); + scalesrc = - value + 1; scaledest = 1; } else { - scaledest = abs ((gint) adj->value + 1); - scalesrc = 1; + scalesrc = 1; + scaledest = value + 1; } - nav_dialog->block_adj_sig = TRUE; - gimp_display_shell_scale (nav_dialog->disp_shell, - (scaledest * 100) + scalesrc); - nav_dialog->block_adj_sig = FALSE; + g_print ("zoom_adj_changed: %d : %d (%f)\n", scaledest, scalesrc, + adj->value); + + gimp_display_shell_scale (view->shell, (scaledest * 100) + scalesrc); } static void -nav_dialog_display_changed (GimpContext *context, - GimpDisplay *gdisp, - NavigationDialog *nav_dialog) +gimp_navigation_view_zoom_out_clicked (GtkWidget *widget, + GimpNavigationView *view) { - GimpDisplay *old_gdisp = NULL; - GimpImage *gimage; - gchar *title; - - if (nav_dialog->disp_shell) - old_gdisp = nav_dialog->disp_shell->gdisp; - - if (gdisp == old_gdisp || ! gdisp) - return; - - gtk_widget_set_sensitive (nav_window_auto->shell, TRUE); - - nav_dialog->frozen = FALSE; - - title = nav_dialog_title (GIMP_DISPLAY_SHELL (gdisp->shell)); - - gtk_window_set_title (GTK_WINDOW (nav_dialog->shell), title); - - g_free (title); - - gimage = gdisp->gimage; - - if (gimage && gimp_container_have (context->gimp->images, - GIMP_OBJECT (gimage))) - { - nav_dialog->disp_shell = GIMP_DISPLAY_SHELL (gdisp->shell); - - gimp_preview_set_viewable (GIMP_PREVIEW (nav_dialog->preview), - GIMP_VIEWABLE (gdisp->gimage)); - - nav_dialog_update (nav_dialog); - } + if (view->shell) + gimp_display_shell_scale (view->shell, GIMP_ZOOM_OUT); +} + +static void +gimp_navigation_view_zoom_in_clicked (GtkWidget *widget, + GimpNavigationView *view) +{ + if (view->shell) + gimp_display_shell_scale (view->shell, GIMP_ZOOM_IN); +} + +static void +gimp_navigation_view_zoom_100_clicked (GtkWidget *widget, + GimpNavigationView *view) +{ + if (view->shell) + gimp_display_shell_scale (view->shell, 101); +} + +static void +gimp_navigation_view_zoom_fit_clicked (GtkWidget *widget, + GimpNavigationView *view) +{ + if (view->shell) + gimp_display_shell_scale_fit (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), "%d:%d", + SCALEDEST (view->shell->gdisp), + SCALESRC (view->shell->gdisp)); + + gtk_label_set_text (GTK_LABEL (view->zoom_label), scale_str); + } + + if (view->zoom_adjustment) + { + gdouble f; + gint val; + + f = (((gdouble) SCALEDEST (view->shell->gdisp)) / + ((gdouble) SCALESRC (view->shell->gdisp))); + + if (f < 1.0) + val = - RINT (1.0 / f) + 1; + else + val = RINT (f) - 1; + + g_signal_handlers_block_by_func (G_OBJECT (view->zoom_adjustment), + gimp_navigation_view_zoom_adj_changed, + view); + + gtk_adjustment_set_value (view->zoom_adjustment, val); + + g_signal_handlers_unblock_by_func (G_OBJECT (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_update_marker (GimpNavigationView *view) +{ + gdouble xratio; + gdouble yratio; /* Screen res ratio */ + + xratio = SCALEFACTOR_X (view->shell->gdisp); + yratio = SCALEFACTOR_Y (view->shell->gdisp); + + if (GIMP_PREVIEW (view->preview)->dot_for_dot != + view->shell->gdisp->dot_for_dot) + gimp_preview_set_dot_for_dot (GIMP_PREVIEW (view->preview), + view->shell->gdisp->dot_for_dot); + + gimp_navigation_preview_set_marker (GIMP_NAVIGATION_PREVIEW (view->preview), + RINT (view->shell->offset_x / xratio), + RINT (view->shell->offset_y / yratio), + RINT (view->shell->disp_width / xratio), + RINT (view->shell->disp_height / yratio)); } diff --git a/app/display/gimpnavigationeditor.h b/app/display/gimpnavigationeditor.h new file mode 100644 index 0000000000..44c41a9dc0 --- /dev/null +++ b/app/display/gimpnavigationeditor.h @@ -0,0 +1,77 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpnavigationview.h + * Copyright (C) 2002 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas + * + * 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; + + 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_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); +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__ */ diff --git a/app/display/gimpnavigationview.c b/app/display/gimpnavigationview.c index 9301a18b97..4a27097f32 100644 --- a/app/display/gimpnavigationview.c +++ b/app/display/gimpnavigationview.c @@ -1,6 +1,12 @@ /* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * + * gimpnavigationview.c + * Copyright (C) 2001 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas + * * 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 @@ -18,140 +24,126 @@ #include "config.h" -#include - #include -#include -#include "libgimpmath/gimpmath.h" #include "libgimpwidgets/gimpwidgets.h" -#include "widgets/widgets-types.h" - -#include "base/temp-buf.h" +#include "display-types.h" #include "core/gimp.h" -#include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" -#include "core/gimplist.h" - -#include "file/file-utils.h" - -#include "display/gimpdisplay.h" -#include "display/gimpdisplay-foreach.h" -#include "display/gimpdisplayshell.h" -#include "display/gimpdisplayshell-scroll.h" -#include "display/gimpdisplayshell-scale.h" #include "widgets/gimpnavigationpreview.h" -#include "app_procs.h" +#include "gimpdisplay.h" +#include "gimpdisplayshell.h" +#include "gimpdisplayshell-scale.h" +#include "gimpdisplayshell-scroll.h" +#include "gimpnavigationview.h" + #include "gimprc.h" -#include "nav_window.h" #include "libgimp/gimpintl.h" -#define BORDER_PEN_WIDTH 3 -#define MAX_SCALE_BUF 20 +#define MAX_SCALE_BUF 20 -struct _NavigationDialog +static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass); +static void gimp_navigation_view_init (GimpNavigationView *view); + +static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell, + gboolean popup); + +static gboolean gimp_navigation_view_button_release (GtkWidget *widget, + GdkEventButton *bevent, + GimpDisplayShell *shell); +static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview, + gint x, + gint 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_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_update_marker (GimpNavigationView *view); + + +static GimpEditorClass *parent_class = NULL; + + +GType +gimp_navigation_view_get_type (void) { - GtkWidget *shell; + static GType view_type = 0; - GtkWidget *preview; + if (! view_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, + }; - GtkWidget *zoom_label; - GtkObject *zoom_adjustment; - GimpDisplayShell *disp_shell; + view_type = g_type_register_static (GIMP_TYPE_EDITOR, + "GimpNavigationView", + &view_info, 0); + } - gboolean block_adj_sig; - gboolean frozen; -}; + return view_type; +} - -static NavigationDialog * nav_dialog_new (GimpDisplayShell *shell); - -static gchar * nav_dialog_title (GimpDisplayShell *shell); -static GtkWidget * nav_dialog_create_preview (NavigationDialog *nav_dialog, - GimpImage *gimage); -static void nav_dialog_update_marker (NavigationDialog *nav_dialog); -static void nav_dialog_close_callback (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_marker_changed (GimpNavigationPreview *preview, - gint x, - gint y, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom (GimpNavigationPreview *preview, - GimpZoomType direction, - NavigationDialog *nav_dialog); -static void nav_dialog_scroll (GimpNavigationPreview *preview, - GdkScrollDirection direction, - NavigationDialog *nav_dialog); -static gboolean nav_dialog_button_release (GtkWidget *widget, - GdkEventButton *bevent, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_in (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_out (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_adj_changed (GtkAdjustment *adj, - NavigationDialog *nav_dialog); -static void nav_dialog_display_changed (GimpContext *context, - GimpDisplay *gdisp, - NavigationDialog *nav_dialog); - - -static NavigationDialog *nav_window_auto = NULL; - - -/* public functions */ - -NavigationDialog * -nav_dialog_create (GimpDisplayShell *shell) +static void +gimp_navigation_view_class_init (GimpNavigationViewClass *klass) { - NavigationDialog *nav_dialog; - GtkWidget *abox; - GtkWidget *frame; - GtkWidget *hbox; - GtkWidget *button; - GtkWidget *image; - GtkWidget *hscale; - gchar *title; - gchar scale_str[MAX_SCALE_BUF]; + GObjectClass *object_class; - title = nav_dialog_title (shell); + object_class = G_OBJECT_CLASS (klass); - nav_dialog = nav_dialog_new (shell); + parent_class = g_type_class_peek_parent (klass); +} - nav_dialog->shell = gimp_dialog_new (title, "navigation_dialog", - gimp_standard_help_func, - "dialogs/navigation_window.html", - GTK_WIN_POS_MOUSE, - FALSE, TRUE, TRUE, +static void +gimp_navigation_view_init (GimpNavigationView *view) +{ + GtkWidget *abox; + GtkWidget *frame; - "_delete_event_", - nav_dialog_close_callback, - nav_dialog, NULL, NULL, TRUE, TRUE, - - NULL); - - g_free (title); - - gtk_dialog_set_has_separator (GTK_DIALOG (nav_dialog->shell), FALSE); - gtk_widget_hide (GTK_DIALOG (nav_dialog->shell)->action_area); - - g_object_weak_ref (G_OBJECT (nav_dialog->shell), - (GWeakNotify) g_free, - nav_dialog); + view->shell = NULL; /* the 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_box_pack_start (GTK_BOX (view), abox, TRUE, TRUE, 0); gtk_widget_show (abox); frame = gtk_frame_new (NULL); @@ -159,128 +151,119 @@ nav_dialog_create (GimpDisplayShell *shell) gtk_container_add (GTK_CONTAINER (abox), frame); gtk_widget_show (frame); - nav_dialog->preview = nav_dialog_create_preview (nav_dialog, - shell->gdisp->gimage); - gtk_container_add (GTK_CONTAINER (frame), nav_dialog->preview); - gtk_widget_show (nav_dialog->preview); + view->preview = gimp_navigation_preview_new (NULL, gimprc.nav_preview_size); + gtk_container_add (GTK_CONTAINER (frame), view->preview); + gtk_widget_show (view->preview); - nav_dialog_update_marker (nav_dialog); + g_signal_connect (G_OBJECT (view->preview), "marker_changed", + G_CALLBACK (gimp_navigation_view_marker_changed), + view); + g_signal_connect (G_OBJECT (view->preview), "zoom", + G_CALLBACK (gimp_navigation_view_zoom), + view); + g_signal_connect (G_OBJECT (view->preview), "scroll", + G_CALLBACK (gimp_navigation_view_scroll), + view); - /* the zoom scale */ + gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE); +} - nav_dialog->zoom_adjustment = - gtk_adjustment_new (0.0, -15.0, 16.0, 1.0, 1.0, 1.0); - g_signal_connect (G_OBJECT (nav_dialog->zoom_adjustment), "value_changed", - G_CALLBACK (nav_dialog_zoom_adj_changed), - nav_dialog); +/* public functions */ - 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_end (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), hscale, - FALSE, FALSE, 0); - gtk_widget_show (hscale); - - /* the zoom buttons */ - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), hbox, - FALSE, FALSE, 0); - gtk_widget_show (hbox); - - button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - 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); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (nav_dialog_zoom_out), - nav_dialog); - - /* user zoom ratio */ - g_snprintf (scale_str, sizeof (scale_str), "%d:%d", - SCALEDEST (nav_dialog->disp_shell->gdisp), - SCALESRC (nav_dialog->disp_shell->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); - - button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - 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); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (nav_dialog_zoom_in), - nav_dialog); - - return nav_dialog; +GtkWidget * +gimp_navigation_view_new (GimpDisplayShell *shell) +{ + return gimp_navigation_view_new_private (shell, FALSE); } void -nav_dialog_create_popup (GimpDisplayShell *shell, - GtkWidget *widget, - gint button_x, - gint button_y) +gimp_navigation_view_set_shell (GimpNavigationView *view, + GimpDisplayShell *shell) { - NavigationDialog *nav_dialog; + 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 (G_OBJECT (view->shell), + gimp_navigation_view_shell_scaled, + view); + g_signal_handlers_disconnect_by_func (G_OBJECT (view->shell), + gimp_navigation_view_shell_scrolled, + view); + } + else if (shell) + { + gtk_widget_set_sensitive (GTK_WIDGET (view), TRUE); + } + + view->shell = shell; + + if (view->shell) + { + gimp_preview_set_viewable (GIMP_PREVIEW (view->preview), + GIMP_VIEWABLE (shell->gdisp->gimage)); + + g_signal_connect (G_OBJECT (view->shell), "scaled", + G_CALLBACK (gimp_navigation_view_shell_scaled), + view); + g_signal_connect (G_OBJECT (view->shell), "scrolled", + G_CALLBACK (gimp_navigation_view_shell_scrolled), + view); + + gimp_navigation_view_shell_scaled (view->shell, view); + } + else + { + gimp_preview_set_viewable (GIMP_PREVIEW (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; gint x, y; gint x_org, y_org; gint scr_w, scr_h; + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + g_return_if_fail (GTK_IS_WIDGET (widget)); + if (! shell->nav_popup) { GtkWidget *frame; - GtkWidget *preview_frame; - shell->nav_popup = nav_dialog = nav_dialog_new (shell); - - nav_dialog->shell = gtk_window_new (GTK_WINDOW_POPUP); - - g_object_weak_ref (G_OBJECT (nav_dialog->shell), - (GWeakNotify) g_free, - nav_dialog); + 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 (nav_dialog->shell), frame); + gtk_container_add (GTK_CONTAINER (shell->nav_popup), frame); gtk_widget_show (frame); - preview_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (preview_frame), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (frame), preview_frame); - gtk_widget_show (preview_frame); + view = GIMP_NAVIGATION_VIEW (gimp_navigation_view_new_private (shell, TRUE)); + gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view)); + gtk_widget_show (GTK_WIDGET (view)); - nav_dialog->preview = nav_dialog_create_preview (nav_dialog, - shell->gdisp->gimage); - gtk_container_add (GTK_CONTAINER (preview_frame), nav_dialog->preview); - gtk_widget_show (nav_dialog->preview); - - g_signal_connect (G_OBJECT (nav_dialog->preview), "button_release_event", - G_CALLBACK (nav_dialog_button_release), - nav_dialog); + g_signal_connect (G_OBJECT (view->preview), "button_release_event", + G_CALLBACK (gimp_navigation_view_button_release), + shell); } else { - nav_dialog = shell->nav_popup; - - gtk_widget_hide (nav_dialog->shell); + view = GIMP_NAVIGATION_VIEW (GTK_BIN (GTK_BIN (shell->nav_popup)->child)->child);; } - nav_dialog_update_marker (nav_dialog); - - preview = GIMP_NAVIGATION_PREVIEW (nav_dialog->preview); + preview = GIMP_NAVIGATION_PREVIEW (view->preview); /* decide where to put the popup */ gdk_window_get_origin (widget->window, &x_org, &y_org); @@ -288,13 +271,16 @@ nav_dialog_create_popup (GimpDisplayShell *shell, scr_w = gdk_screen_width (); scr_h = gdk_screen_height (); - x = (x_org + button_x - - preview->p_x - - ((preview->p_width - BORDER_PEN_WIDTH + 1) * 0.5) - 2); +#define BORDER_WIDTH (2 * widget->style->xthickness) +#define BORDER_HEIGHT (2 * widget->style->ythickness) - y = (y_org + button_y - + x = (x_org + click_x - + preview->p_x - + ((preview->p_width - BORDER_WIDTH) * 0.5) - 2); + + y = (y_org + click_y - preview->p_y - - ((preview->p_height - BORDER_PEN_WIDTH + 1) * 0.5) - 2); + ((preview->p_height - BORDER_HEIGHT) * 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 @@ -310,436 +296,336 @@ nav_dialog_create_popup (GimpDisplayShell *shell, x = (x + preview->p_width > scr_w) ? scr_w - preview->p_width - 2 : x; y = (y + preview->p_height > scr_h) ? scr_h - preview->p_height - 2 : y; - gtk_window_move (GTK_WINDOW (nav_dialog->shell), x, y); - gtk_widget_show (nav_dialog->shell); + 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 = - (preview->p_width - BORDER_PEN_WIDTH + 1) * 0.5; + preview->motion_offset_x = (preview->p_width - BORDER_WIDTH) * 0.5; + preview->motion_offset_y = (preview->p_height - BORDER_HEIGHT) * 0.5; - preview->motion_offset_y = - (preview->p_height - BORDER_PEN_WIDTH + 1) * 0.5; +#undef BORDER_WIDTH +#undef BORDER_HEIGHT gimp_navigation_preview_grab_pointer (preview); } -void -nav_dialog_free (GimpDisplayShell *del_shell, - NavigationDialog *nav_dialog) -{ - /* So this functions works both ways.. - * it will come in here with nav_dialog == null - * if the auto mode is on... - */ - - if (nav_dialog) - { - gtk_widget_destroy (nav_dialog->shell); - } - else if (nav_window_auto) - { - GimpDisplay *gdisp = NULL; - GList *list; - - /* Only freeze if we are displaying the image we have deleted */ - if (nav_window_auto->disp_shell != del_shell) - return; - - for (list = GIMP_LIST (the_gimp->images)->list; - list; - list = g_list_next (list)) - { - gdisp = gdisplays_check_valid (NULL, GIMP_IMAGE (list->data)); - - if (gdisp) - break; - } - - if (gdisp) - { - nav_dialog_display_changed (NULL, gdisp, nav_window_auto); - } - else - { - /* Clear window and freeze */ - nav_window_auto->frozen = TRUE; - gtk_window_set_title (GTK_WINDOW (nav_window_auto->shell), - _("Navigation: No Image")); - - gtk_widget_set_sensitive (nav_window_auto->shell, FALSE); - nav_window_auto->disp_shell = NULL; - gtk_widget_hide (GTK_WIDGET (nav_window_auto->shell)); - } - } -} - -void -nav_dialog_show (NavigationDialog *nav_dialog) -{ - g_return_if_fail (nav_dialog != NULL); - - if (! GTK_WIDGET_VISIBLE (nav_dialog->shell)) - { - gtk_widget_show (nav_dialog->shell); - } - else - { - gdk_window_raise (nav_dialog->shell->window); - } -} - -void -nav_dialog_show_auto (Gimp *gimp) -{ - GimpContext *context; - GimpDisplay *gdisp; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - - context = gimp_get_user_context (gimp); - - gdisp = gimp_context_get_display (context); - - if (! gdisp) - return; - - if (! nav_window_auto) - { - nav_window_auto = nav_dialog_create (GIMP_DISPLAY_SHELL (gdisp->shell)); - - g_signal_connect (G_OBJECT (context), "display_changed", - G_CALLBACK (nav_dialog_display_changed), - nav_window_auto); - } - - nav_dialog_show (nav_window_auto); - - gtk_widget_set_sensitive (nav_window_auto->shell, TRUE); - - nav_window_auto->frozen = FALSE; -} - -void -nav_dialog_update (NavigationDialog *nav_dialog) -{ - /* So this functions works both ways.. - * it will come in here with info_win == null - * if the auto mode is on... - */ - - if (! nav_dialog) - { - if (nav_window_auto && ! nav_window_auto->frozen) - { - nav_dialog_update (nav_window_auto); - } - - return; - } - - if (! GTK_WIDGET_VISIBLE (nav_dialog->shell)) - return; - - if (nav_dialog->zoom_label) - { - gchar scale_str[MAX_SCALE_BUF]; - - /* Update the zoom scale string */ - g_snprintf (scale_str, sizeof (scale_str), "%d:%d", - SCALEDEST (nav_dialog->disp_shell->gdisp), - SCALESRC (nav_dialog->disp_shell->gdisp)); - - gtk_label_set_text (GTK_LABEL (nav_dialog->zoom_label), scale_str); - } - - if (nav_dialog->zoom_adjustment) - { - GtkAdjustment *adj; - gdouble f; - gdouble val; - - adj = GTK_ADJUSTMENT (nav_dialog->zoom_adjustment); - - f = (((gdouble) SCALEDEST (nav_dialog->disp_shell->gdisp)) / - ((gdouble) SCALESRC (nav_dialog->disp_shell->gdisp))); - - if (f < 1.0) - val = -1.0 / f; - else - val = f; - - if (abs ((gint) adj->value) != (gint) (val - 1) && - ! nav_dialog->block_adj_sig) - { - adj->value = val; - - gtk_adjustment_changed (GTK_ADJUSTMENT (nav_dialog->zoom_adjustment)); - } - } - - nav_dialog_update_marker (nav_dialog); -} - -void -nav_dialog_preview_resized (NavigationDialog *nav_dialog) -{ - if (! nav_dialog) - return; -} - /* private functions */ -static NavigationDialog * -nav_dialog_new (GimpDisplayShell *shell) -{ - NavigationDialog *nav_dialog; - - nav_dialog = g_new0 (NavigationDialog, 1); - - nav_dialog->shell = NULL; - nav_dialog->preview = NULL; - nav_dialog->zoom_label = NULL; - nav_dialog->zoom_adjustment = NULL; - nav_dialog->disp_shell = shell; - - nav_dialog->block_adj_sig = FALSE; - nav_dialog->frozen = FALSE; - - return nav_dialog; -} - -static gchar * -nav_dialog_title (GimpDisplayShell *shell) -{ - gchar *basename; - gchar *title; - - basename = file_utils_uri_to_utf8_basename (gimp_image_get_uri (shell->gdisp->gimage)); - - title = g_strdup_printf (_("Navigation: %s-%d.%d"), - basename, - gimp_image_get_ID (shell->gdisp->gimage), - shell->gdisp->instance); - - g_free (basename); - - return title; -} - static GtkWidget * -nav_dialog_create_preview (NavigationDialog *nav_dialog, - GimpImage *gimage) +gimp_navigation_view_new_private (GimpDisplayShell *shell, + gboolean popup) { - GtkWidget *preview; + GimpNavigationView *view; - preview = gimp_navigation_preview_new (gimage, gimprc.nav_preview_size); + g_return_val_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell), NULL); - g_signal_connect (G_OBJECT (preview), "marker_changed", - G_CALLBACK (nav_dialog_marker_changed), - nav_dialog); - 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); + view = g_object_new (GIMP_TYPE_NAVIGATION_VIEW, NULL); - return preview; -} - -static void -nav_dialog_update_marker (NavigationDialog *nav_dialog) -{ - GimpImage *gimage; - gdouble xratio; - gdouble yratio; /* Screen res ratio */ - - /* Calculate preview size */ - gimage = nav_dialog->disp_shell->gdisp->gimage; - - xratio = SCALEFACTOR_X (nav_dialog->disp_shell->gdisp); - yratio = SCALEFACTOR_Y (nav_dialog->disp_shell->gdisp); - - if (GIMP_PREVIEW (nav_dialog->preview)->dot_for_dot != - nav_dialog->disp_shell->gdisp->dot_for_dot) - gimp_preview_set_dot_for_dot (GIMP_PREVIEW (nav_dialog->preview), - nav_dialog->disp_shell->gdisp->dot_for_dot); - - gimp_navigation_preview_set_marker - (GIMP_NAVIGATION_PREVIEW (nav_dialog->preview), - RINT (nav_dialog->disp_shell->offset_x / xratio), - RINT (nav_dialog->disp_shell->offset_y / yratio), - RINT (nav_dialog->disp_shell->disp_width / xratio), - RINT (nav_dialog->disp_shell->disp_height / yratio)); -} - -static void -nav_dialog_close_callback (GtkWidget *widget, - NavigationDialog *nav_dialog) -{ - gtk_widget_hide (nav_dialog->shell); -} - -static void -nav_dialog_marker_changed (GimpNavigationPreview *nav_preview, - gint x, - gint y, - NavigationDialog *nav_dialog) -{ - gdouble xratio; - gdouble yratio; - gint xoffset; - gint yoffset; - - xratio = SCALEFACTOR_X (nav_dialog->disp_shell->gdisp); - yratio = SCALEFACTOR_Y (nav_dialog->disp_shell->gdisp); - - xoffset = x * xratio - nav_dialog->disp_shell->offset_x; - yoffset = y * yratio - nav_dialog->disp_shell->offset_y; - - gimp_display_shell_scroll (nav_dialog->disp_shell, xoffset, yoffset); -} - -static void -nav_dialog_zoom (GimpNavigationPreview *nav_preview, - GimpZoomType direction, - NavigationDialog *nav_dialog) -{ - gimp_display_shell_scale (nav_dialog->disp_shell, direction); -} - -static void -nav_dialog_scroll (GimpNavigationPreview *nav_preview, - GdkScrollDirection direction, - NavigationDialog *nav_dialog) -{ - GtkAdjustment *adj = NULL; - gdouble value; - - switch (direction) + if (! popup) { - case GDK_SCROLL_LEFT: - case GDK_SCROLL_RIGHT: - adj = nav_dialog->disp_shell->hsbdata; - break; + GtkWidget *hscale; - case GDK_SCROLL_UP: - case GDK_SCROLL_DOWN: - adj = nav_dialog->disp_shell->vsbdata; - break; + /* the editor buttons */ + + view->zoom_out_button = + gimp_editor_add_button (GIMP_EDITOR (view), + GTK_STOCK_ZOOM_OUT, + _("Zoom out"), NULL, + 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"), NULL, + 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"), NULL, + G_CALLBACK (gimp_navigation_view_zoom_100_clicked), + NULL, + view); + + view->zoom_fit_button = + gimp_editor_add_button (GIMP_EDITOR (view), + GTK_STOCK_ZOOM_FIT, + _("Zoom to fit window"), NULL, + G_CALLBACK (gimp_navigation_view_zoom_fit_clicked), + NULL, + view); + + view->shrink_wrap_button = + gimp_editor_add_button (GIMP_EDITOR (view), + GTK_STOCK_ZOOM_FIT, + _("Shrink Wrap"), NULL, + G_CALLBACK (gimp_navigation_view_shrink_clicked), + NULL, + view); + + /* the zoom scale */ + + view->zoom_adjustment = + GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -15.0, 15.0, 1.0, 1.0, 0.0)); + + g_signal_connect (G_OBJECT (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), 0); + gtk_box_pack_end (GTK_BOX (view), hscale, FALSE, FALSE, 0); + gtk_widget_show (hscale); + + /* the zoom label */ + + view->zoom_label = gtk_label_new ("1:1"); + gtk_box_pack_end (GTK_BOX (view), view->zoom_label, FALSE, FALSE, 0); + gtk_widget_show (view->zoom_label); } - g_assert (adj != NULL); + if (shell) + gimp_navigation_view_set_shell (view, shell); - 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); + return GTK_WIDGET (view); } static gboolean -nav_dialog_button_release (GtkWidget *widget, - GdkEventButton *bevent, - NavigationDialog *nav_dialog) +gimp_navigation_view_button_release (GtkWidget *widget, + GdkEventButton *bevent, + GimpDisplayShell *shell) { if (bevent->button == 1) { - gtk_widget_hide (nav_dialog->shell); + gtk_widget_hide (shell->nav_popup); } return FALSE; } static void -nav_dialog_zoom_in (GtkWidget *widget, - NavigationDialog *nav_dialog) +gimp_navigation_view_marker_changed (GimpNavigationPreview *preview, + gint x, + gint y, + GimpNavigationView *view) { - gimp_display_shell_scale (nav_dialog->disp_shell, GIMP_ZOOM_IN); + if (view->shell) + { + gdouble xratio; + gdouble yratio; + gint xoffset; + gint yoffset; + + xratio = SCALEFACTOR_X (view->shell->gdisp); + yratio = SCALEFACTOR_Y (view->shell->gdisp); + + xoffset = x * xratio - view->shell->offset_x; + yoffset = y * yratio - view->shell->offset_y; + + gimp_display_shell_scroll (view->shell, xoffset, yoffset); + } } static void -nav_dialog_zoom_out (GtkWidget *widget, - NavigationDialog *nav_dialog) +gimp_navigation_view_zoom (GimpNavigationPreview *preview, + GimpZoomType direction, + GimpNavigationView *view) { - gimp_display_shell_scale (nav_dialog->disp_shell, GIMP_ZOOM_OUT); + if (view->shell) + { + gimp_display_shell_scale (view->shell, direction); + } } static void -nav_dialog_zoom_adj_changed (GtkAdjustment *adj, - NavigationDialog *nav_dialog) +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) +{ + gint value; gint scalesrc; gint scaledest; - if (adj->value < 0.0) + value = RINT (adj->value); + + if (value < 0) { - scalesrc = abs ((gint) adj->value - 1); + scalesrc = - value + 1; scaledest = 1; } else { - scaledest = abs ((gint) adj->value + 1); - scalesrc = 1; + scalesrc = 1; + scaledest = value + 1; } - nav_dialog->block_adj_sig = TRUE; - gimp_display_shell_scale (nav_dialog->disp_shell, - (scaledest * 100) + scalesrc); - nav_dialog->block_adj_sig = FALSE; + g_print ("zoom_adj_changed: %d : %d (%f)\n", scaledest, scalesrc, + adj->value); + + gimp_display_shell_scale (view->shell, (scaledest * 100) + scalesrc); } static void -nav_dialog_display_changed (GimpContext *context, - GimpDisplay *gdisp, - NavigationDialog *nav_dialog) +gimp_navigation_view_zoom_out_clicked (GtkWidget *widget, + GimpNavigationView *view) { - GimpDisplay *old_gdisp = NULL; - GimpImage *gimage; - gchar *title; - - if (nav_dialog->disp_shell) - old_gdisp = nav_dialog->disp_shell->gdisp; - - if (gdisp == old_gdisp || ! gdisp) - return; - - gtk_widget_set_sensitive (nav_window_auto->shell, TRUE); - - nav_dialog->frozen = FALSE; - - title = nav_dialog_title (GIMP_DISPLAY_SHELL (gdisp->shell)); - - gtk_window_set_title (GTK_WINDOW (nav_dialog->shell), title); - - g_free (title); - - gimage = gdisp->gimage; - - if (gimage && gimp_container_have (context->gimp->images, - GIMP_OBJECT (gimage))) - { - nav_dialog->disp_shell = GIMP_DISPLAY_SHELL (gdisp->shell); - - gimp_preview_set_viewable (GIMP_PREVIEW (nav_dialog->preview), - GIMP_VIEWABLE (gdisp->gimage)); - - nav_dialog_update (nav_dialog); - } + if (view->shell) + gimp_display_shell_scale (view->shell, GIMP_ZOOM_OUT); +} + +static void +gimp_navigation_view_zoom_in_clicked (GtkWidget *widget, + GimpNavigationView *view) +{ + if (view->shell) + gimp_display_shell_scale (view->shell, GIMP_ZOOM_IN); +} + +static void +gimp_navigation_view_zoom_100_clicked (GtkWidget *widget, + GimpNavigationView *view) +{ + if (view->shell) + gimp_display_shell_scale (view->shell, 101); +} + +static void +gimp_navigation_view_zoom_fit_clicked (GtkWidget *widget, + GimpNavigationView *view) +{ + if (view->shell) + gimp_display_shell_scale_fit (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), "%d:%d", + SCALEDEST (view->shell->gdisp), + SCALESRC (view->shell->gdisp)); + + gtk_label_set_text (GTK_LABEL (view->zoom_label), scale_str); + } + + if (view->zoom_adjustment) + { + gdouble f; + gint val; + + f = (((gdouble) SCALEDEST (view->shell->gdisp)) / + ((gdouble) SCALESRC (view->shell->gdisp))); + + if (f < 1.0) + val = - RINT (1.0 / f) + 1; + else + val = RINT (f) - 1; + + g_signal_handlers_block_by_func (G_OBJECT (view->zoom_adjustment), + gimp_navigation_view_zoom_adj_changed, + view); + + gtk_adjustment_set_value (view->zoom_adjustment, val); + + g_signal_handlers_unblock_by_func (G_OBJECT (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_update_marker (GimpNavigationView *view) +{ + gdouble xratio; + gdouble yratio; /* Screen res ratio */ + + xratio = SCALEFACTOR_X (view->shell->gdisp); + yratio = SCALEFACTOR_Y (view->shell->gdisp); + + if (GIMP_PREVIEW (view->preview)->dot_for_dot != + view->shell->gdisp->dot_for_dot) + gimp_preview_set_dot_for_dot (GIMP_PREVIEW (view->preview), + view->shell->gdisp->dot_for_dot); + + gimp_navigation_preview_set_marker (GIMP_NAVIGATION_PREVIEW (view->preview), + RINT (view->shell->offset_x / xratio), + RINT (view->shell->offset_y / yratio), + RINT (view->shell->disp_width / xratio), + RINT (view->shell->disp_height / yratio)); } diff --git a/app/display/gimpnavigationview.h b/app/display/gimpnavigationview.h new file mode 100644 index 0000000000..44c41a9dc0 --- /dev/null +++ b/app/display/gimpnavigationview.h @@ -0,0 +1,77 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpnavigationview.h + * Copyright (C) 2002 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas + * + * 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; + + 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_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); +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__ */ diff --git a/app/gimprc.c b/app/gimprc.c index d31e2e18a5..66dbc937c7 100644 --- a/app/gimprc.c +++ b/app/gimprc.c @@ -212,7 +212,6 @@ GimpRc gimprc = /* max_new_image_size */ 33554432, /* 32 MB */ /* trust_dirty_flag */ FALSE, /* use_help */ TRUE, - /* nav_window_per_display */ FALSE, /* info_window_follows_mouse */ TRUE, /* help_browser */ GIMP_HELP_BROWSER_GIMP, /* cursor_mode */ GIMP_CURSOR_MODE_TOOL_ICON, @@ -272,8 +271,6 @@ static ParseFunc funcs[] = { "dont-trust-dirty-flag", TT_BOOLEAN, NULL, &gimprc.trust_dirty_flag }, { "use-help", TT_BOOLEAN, &gimprc.use_help, NULL }, { "dont-use-help", TT_BOOLEAN, NULL, &gimprc.use_help }, - { "nav-window-per-display", TT_BOOLEAN, &gimprc.nav_window_per_display, NULL }, - { "nav-window-follows-auto", TT_BOOLEAN, NULL, &gimprc.nav_window_per_display }, { "info-window-follows-mouse", TT_BOOLEAN, &gimprc.info_window_follows_mouse, NULL }, { "info-window-per-display", TT_BOOLEAN, NULL, &gimprc.info_window_follows_mouse }, { "help-browser", TT_XHELPBROWSER, &gimprc.help_browser, NULL }, diff --git a/app/gimprc.h b/app/gimprc.h index 81f7fce7d9..dc4b6a3f8c 100644 --- a/app/gimprc.h +++ b/app/gimprc.h @@ -59,7 +59,6 @@ struct _GimpRc guint max_new_image_size; gboolean trust_dirty_flag; gboolean use_help; - gboolean nav_window_per_display; gboolean info_window_follows_mouse; gint help_browser; gint cursor_mode; diff --git a/app/gui/dialogs-constructors.c b/app/gui/dialogs-constructors.c index 9a0b74ba54..fdc59a71b0 100644 --- a/app/gui/dialogs-constructors.c +++ b/app/gui/dialogs-constructors.c @@ -64,6 +64,7 @@ #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell-filter-dialog.h" +#include "display/gimpnavigationview.h" #include "about-dialog.h" #include "brushes-commands.h" @@ -126,6 +127,8 @@ static void dialogs_set_path_context_func (GimpDockable *dockable, GimpContext *context); static void dialogs_set_indexed_palette_context_func (GimpDockable *dockable, GimpContext *context); +static void dialogs_set_navigation_context_func (GimpDockable *dockable, + GimpContext *context); static GtkWidget * dialogs_dockable_new (GtkWidget *widget, const gchar *name, @@ -142,6 +145,9 @@ static void dialogs_path_view_image_changed (GimpContext *context, static void dialogs_indexed_palette_image_changed (GimpContext *context, GimpImage *gimage, GimpColormapEditor *editor); +static void dialogs_navigation_display_changed (GimpContext *context, + GimpDisplay *gdisp, + GimpNavigationView *view); /**********************/ @@ -900,6 +906,31 @@ dialogs_edit_palette_func (GimpData *data) } +/* display views */ + +GtkWidget * +dialogs_navigation_view_new (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size) +{ + GimpDisplay *gdisp; + GimpDisplayShell *shell = NULL; + GtkWidget *view; + + gdisp = gimp_context_get_display (context); + + if (gdisp) + shell = GIMP_DISPLAY_SHELL (gdisp->shell); + + view = gimp_navigation_view_new (shell); + + return dialogs_dockable_new (view, + _("Display Navigation"), _("Navigation"), + NULL, + dialogs_set_navigation_context_func); +} + + /* private functions */ static void @@ -1243,6 +1274,41 @@ dialogs_set_indexed_palette_context_func (GimpDockable *dockable, } } +static void +dialogs_set_navigation_context_func (GimpDockable *dockable, + GimpContext *context) +{ + GimpNavigationView *view; + + view = (GimpNavigationView *) g_object_get_data (G_OBJECT (dockable), + "gimp-dialogs-view"); + + if (view) + { + if (dockable->context) + { + g_signal_handlers_disconnect_by_func (G_OBJECT (dockable->context), + dialogs_navigation_display_changed, + view); + } + + if (context) + { + g_signal_connect (G_OBJECT (context), "display_changed", + G_CALLBACK (dialogs_navigation_display_changed), + view); + + dialogs_navigation_display_changed (context, + gimp_context_get_display (context), + view); + } + else + { + dialogs_navigation_display_changed (NULL, NULL, view); + } + } +} + static GtkWidget * dialogs_dockable_new (GtkWidget *widget, const gchar *name, @@ -1287,3 +1353,16 @@ dialogs_indexed_palette_image_changed (GimpContext *context, { gimp_colormap_editor_set_image (editor, gimage); } + +static void +dialogs_navigation_display_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); +} diff --git a/app/gui/dialogs-constructors.h b/app/gui/dialogs-constructors.h index 87cb12aa9e..c9e8379816 100644 --- a/app/gui/dialogs-constructors.h +++ b/app/gui/dialogs-constructors.h @@ -143,5 +143,9 @@ GtkWidget * dialogs_palette_editor_get (GimpDialogFactory *factory, gint preview_size); void dialogs_edit_palette_func (GimpData *data); +GtkWidget * dialogs_navigation_view_new (GimpDialogFactory *factory, + GimpContext *context, + gint preview_size); + #endif /* __DIALOGS_CONSTRUCTORS_H__ */ diff --git a/app/gui/dialogs.c b/app/gui/dialogs.c index ee3049fdc4..e4263b9bd3 100644 --- a/app/gui/dialogs.c +++ b/app/gui/dialogs.c @@ -79,7 +79,9 @@ static const GimpDialogFactoryEntry dock_entries[] = { "gimp-brush-editor", dialogs_brush_editor_get, 0, TRUE, FALSE, FALSE, TRUE }, { "gimp-gradient-editor", dialogs_gradient_editor_get, 0, TRUE, FALSE, FALSE, TRUE }, - { "gimp-palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE } + { "gimp-palette-editor", dialogs_palette_editor_get, 0, TRUE, FALSE, FALSE, TRUE }, + + { "gimp-navigation-view", dialogs_navigation_view_new, 0, FALSE, FALSE, FALSE, TRUE } }; diff --git a/app/gui/menus.c b/app/gui/menus.c index b3d00c49fd..87f4090d62 100644 --- a/app/gui/menus.c +++ b/app/gui/menus.c @@ -481,6 +481,10 @@ static GimpItemFactoryEntry image_entries[] = "", GTK_STOCK_ZOOM_FIT }, NULL, "view/zoom.html", NULL }, + { { N_("/View/Shrink Wrap"), "E", + view_shrink_wrap_cmd_callback, 0 }, + NULL, + "view/shrink_wrap.html", NULL }, /* /View/Zoom */ @@ -589,10 +593,6 @@ static GimpItemFactoryEntry image_entries[] = "", GTK_STOCK_NEW }, NULL, "view/new_view.html", NULL }, - { { N_("/View/Shrink Wrap"), "E", - view_shrink_wrap_cmd_callback, 0 }, - NULL, - "view/shrink_wrap.html", NULL }, /* /Image/Mode */ @@ -1364,6 +1364,7 @@ static GimpItemFactoryEntry dialogs_entries[] = "", GTK_STOCK_SELECT_COLOR), ADD_TAB (N_("/Add Tab/Buffers..."), "gimp-buffer-list", NULL, NULL), ADD_TAB (N_("/Add Tab/Images..."), "gimp-image-list", NULL, NULL), + ADD_TAB (N_("/Add Tab/Navigation..."), "gimp-navigation-view", NULL, NULL), SEPARATOR ("/Add Tab/---"), diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index c73b5addf0..7e761db94c 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -172,7 +172,6 @@ static guint old_max_new_image_size; static GimpThumbnailSize old_thumbnail_size; static gboolean old_trust_dirty_flag; static gboolean old_use_help; -static gboolean old_nav_window_per_display; static gboolean old_info_window_follows_mouse; static gint old_help_browser; static gint old_cursor_mode; @@ -185,7 +184,6 @@ static gint edit_min_colors; static gboolean edit_install_cmap; static gboolean edit_cycled_marching_ants; static gint edit_last_opened_size; -static gboolean edit_nav_window_per_display; static gboolean edit_info_window_follows_mouse; static gboolean edit_disable_tearoff_menus; static gchar * edit_temp_path = NULL; @@ -368,7 +366,6 @@ prefs_check_settings (Gimp *gimp) edit_install_cmap != old_install_cmap || edit_cycled_marching_ants != old_cycled_marching_ants || edit_last_opened_size != old_last_opened_size || - edit_nav_window_per_display != old_nav_window_per_display || edit_info_window_follows_mouse != old_info_window_follows_mouse || edit_disable_tearoff_menus != old_disable_tearoff_menus || @@ -506,7 +503,6 @@ prefs_save_callback (GtkWidget *widget, gboolean save_install_cmap; gboolean save_cycled_marching_ants; gint save_last_opened_size; - gboolean save_nav_window_per_display; gboolean save_info_window_follows_mouse; gchar *save_temp_path; gchar *save_swap_path; @@ -557,7 +553,6 @@ prefs_save_callback (GtkWidget *widget, save_install_cmap = gimprc.install_cmap; save_cycled_marching_ants = gimprc.cycled_marching_ants; save_last_opened_size = gimprc.last_opened_size; - save_nav_window_per_display = gimprc.nav_window_per_display; save_info_window_follows_mouse = gimprc.info_window_follows_mouse; save_temp_path = base_config->temp_path; @@ -779,12 +774,6 @@ prefs_save_callback (GtkWidget *widget, gimprc.last_opened_size = edit_last_opened_size; update = g_list_append (update, "last-opened-size"); } - if (edit_nav_window_per_display != old_nav_window_per_display) - { - gimprc.nav_window_per_display = edit_nav_window_per_display; - update = g_list_append (update, "nav-window-per-display"); - remove = g_list_append (remove, "nav-window-follows-auto"); - } if (edit_info_window_follows_mouse != old_info_window_follows_mouse) { gimprc.info_window_follows_mouse = edit_info_window_follows_mouse; @@ -869,7 +858,6 @@ prefs_save_callback (GtkWidget *widget, gimprc.install_cmap = save_install_cmap; gimprc.cycled_marching_ants = save_cycled_marching_ants; gimprc.last_opened_size = save_last_opened_size; - gimprc.nav_window_per_display = save_nav_window_per_display; gimprc.info_window_follows_mouse = save_info_window_follows_mouse; base_config->temp_path = save_temp_path; @@ -952,7 +940,9 @@ prefs_cancel_callback (GtkWidget *widget, if (gimprc.nav_preview_size != old_nav_preview_size) { gimprc.nav_preview_size = old_nav_preview_size; +#if 0 gdisplays_nav_preview_resized (); +#endif } if ((gimprc.transparency_type != old_transparency_type) || (gimprc.transparency_size != old_transparency_size)) @@ -980,7 +970,6 @@ prefs_cancel_callback (GtkWidget *widget, edit_install_cmap = old_install_cmap; edit_cycled_marching_ants = old_cycled_marching_ants; edit_last_opened_size = old_last_opened_size; - edit_nav_window_per_display = old_nav_window_per_display; edit_info_window_follows_mouse = old_info_window_follows_mouse; edit_disable_tearoff_menus = old_disable_tearoff_menus; @@ -1041,7 +1030,6 @@ prefs_toggle_callback (GtkWidget *widget, data == &edit_stingy_memory_use || data == &edit_install_cmap || data == &edit_cycled_marching_ants || - data == &edit_nav_window_per_display || data == &edit_info_window_follows_mouse || data == &edit_disable_tearoff_menus) { @@ -1105,7 +1093,9 @@ prefs_nav_preview_size_callback (GtkWidget *widget, { gimp_menu_item_update (widget, data); +#if 0 gdisplays_nav_preview_resized (); +#endif } static void @@ -1643,7 +1633,6 @@ preferences_dialog_create (Gimp *gimp) edit_install_cmap = gimprc.install_cmap; edit_cycled_marching_ants = gimprc.cycled_marching_ants; edit_last_opened_size = gimprc.last_opened_size; - edit_nav_window_per_display = gimprc.nav_window_per_display; edit_info_window_follows_mouse = gimprc.info_window_follows_mouse; edit_disable_tearoff_menus = gimprc.disable_tearoff_menus; @@ -1718,7 +1707,6 @@ preferences_dialog_create (Gimp *gimp) old_install_cmap = edit_install_cmap; old_cycled_marching_ants = edit_cycled_marching_ants; old_last_opened_size = edit_last_opened_size; - old_nav_window_per_display = edit_nav_window_per_display; old_info_window_follows_mouse = edit_info_window_follows_mouse; old_disable_tearoff_menus = edit_disable_tearoff_menus; @@ -2102,8 +2090,6 @@ preferences_dialog_create (Gimp *gimp) /* Dialog Bahaviour */ vbox2 = prefs_frame_new (_("Dialog Behavior"), GTK_CONTAINER (vbox)); - prefs_check_button_new (_("Navigation Window per Display"), - &edit_nav_window_per_display, GTK_BOX (vbox2)); prefs_check_button_new (_("Info Window Follows Mouse"), &edit_info_window_follows_mouse, GTK_BOX (vbox2)); diff --git a/app/gui/view-commands.c b/app/gui/view-commands.c index d5d957e91a..a83d17ff22 100644 --- a/app/gui/view-commands.c +++ b/app/gui/view-commands.c @@ -42,7 +42,6 @@ #include "view-commands.h" #include "gimprc.h" -#include "nav_window.h" #define return_if_no_display(gdisp, data) \ @@ -136,17 +135,8 @@ view_navigation_window_cmd_callback (GtkWidget *widget, shell = GIMP_DISPLAY_SHELL (gdisp->shell); - if (gimprc.nav_window_per_display) - { - if (! shell->nav_dialog) - shell->nav_dialog = nav_dialog_create (shell); - - nav_dialog_show (shell->nav_dialog); - } - else - { - nav_dialog_show_auto (gdisp->gimage->gimp); - } + gimp_dialog_factory_dialog_raise (global_dock_factory, + "gimp-navigation-view", -1); } void diff --git a/app/menus/menus.c b/app/menus/menus.c index b3d00c49fd..87f4090d62 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -481,6 +481,10 @@ static GimpItemFactoryEntry image_entries[] = "", GTK_STOCK_ZOOM_FIT }, NULL, "view/zoom.html", NULL }, + { { N_("/View/Shrink Wrap"), "E", + view_shrink_wrap_cmd_callback, 0 }, + NULL, + "view/shrink_wrap.html", NULL }, /* /View/Zoom */ @@ -589,10 +593,6 @@ static GimpItemFactoryEntry image_entries[] = "", GTK_STOCK_NEW }, NULL, "view/new_view.html", NULL }, - { { N_("/View/Shrink Wrap"), "E", - view_shrink_wrap_cmd_callback, 0 }, - NULL, - "view/shrink_wrap.html", NULL }, /* /Image/Mode */ @@ -1364,6 +1364,7 @@ static GimpItemFactoryEntry dialogs_entries[] = "", GTK_STOCK_SELECT_COLOR), ADD_TAB (N_("/Add Tab/Buffers..."), "gimp-buffer-list", NULL, NULL), ADD_TAB (N_("/Add Tab/Images..."), "gimp-image-list", NULL, NULL), + ADD_TAB (N_("/Add Tab/Navigation..."), "gimp-navigation-view", NULL, NULL), SEPARATOR ("/Add Tab/---"), diff --git a/app/nav_window.c b/app/nav_window.c deleted file mode 100644 index 9301a18b97..0000000000 --- a/app/nav_window.c +++ /dev/null @@ -1,745 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include - -#include -#include - -#include "libgimpmath/gimpmath.h" -#include "libgimpwidgets/gimpwidgets.h" - -#include "widgets/widgets-types.h" - -#include "base/temp-buf.h" - -#include "core/gimp.h" -#include "core/gimpcontainer.h" -#include "core/gimpcontext.h" -#include "core/gimpimage.h" -#include "core/gimplist.h" - -#include "file/file-utils.h" - -#include "display/gimpdisplay.h" -#include "display/gimpdisplay-foreach.h" -#include "display/gimpdisplayshell.h" -#include "display/gimpdisplayshell-scroll.h" -#include "display/gimpdisplayshell-scale.h" - -#include "widgets/gimpnavigationpreview.h" - -#include "app_procs.h" -#include "gimprc.h" -#include "nav_window.h" - -#include "libgimp/gimpintl.h" - - -#define BORDER_PEN_WIDTH 3 -#define MAX_SCALE_BUF 20 - - -struct _NavigationDialog -{ - GtkWidget *shell; - - GtkWidget *preview; - - GtkWidget *zoom_label; - GtkObject *zoom_adjustment; - GimpDisplayShell *disp_shell; - - gboolean block_adj_sig; - gboolean frozen; -}; - - -static NavigationDialog * nav_dialog_new (GimpDisplayShell *shell); - -static gchar * nav_dialog_title (GimpDisplayShell *shell); -static GtkWidget * nav_dialog_create_preview (NavigationDialog *nav_dialog, - GimpImage *gimage); -static void nav_dialog_update_marker (NavigationDialog *nav_dialog); -static void nav_dialog_close_callback (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_marker_changed (GimpNavigationPreview *preview, - gint x, - gint y, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom (GimpNavigationPreview *preview, - GimpZoomType direction, - NavigationDialog *nav_dialog); -static void nav_dialog_scroll (GimpNavigationPreview *preview, - GdkScrollDirection direction, - NavigationDialog *nav_dialog); -static gboolean nav_dialog_button_release (GtkWidget *widget, - GdkEventButton *bevent, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_in (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_out (GtkWidget *widget, - NavigationDialog *nav_dialog); -static void nav_dialog_zoom_adj_changed (GtkAdjustment *adj, - NavigationDialog *nav_dialog); -static void nav_dialog_display_changed (GimpContext *context, - GimpDisplay *gdisp, - NavigationDialog *nav_dialog); - - -static NavigationDialog *nav_window_auto = NULL; - - -/* public functions */ - -NavigationDialog * -nav_dialog_create (GimpDisplayShell *shell) -{ - NavigationDialog *nav_dialog; - GtkWidget *abox; - GtkWidget *frame; - GtkWidget *hbox; - GtkWidget *button; - GtkWidget *image; - GtkWidget *hscale; - gchar *title; - gchar scale_str[MAX_SCALE_BUF]; - - title = nav_dialog_title (shell); - - nav_dialog = nav_dialog_new (shell); - - nav_dialog->shell = gimp_dialog_new (title, "navigation_dialog", - gimp_standard_help_func, - "dialogs/navigation_window.html", - GTK_WIN_POS_MOUSE, - FALSE, TRUE, TRUE, - - "_delete_event_", - nav_dialog_close_callback, - nav_dialog, NULL, NULL, TRUE, TRUE, - - NULL); - - g_free (title); - - gtk_dialog_set_has_separator (GTK_DIALOG (nav_dialog->shell), FALSE); - gtk_widget_hide (GTK_DIALOG (nav_dialog->shell)->action_area); - - g_object_weak_ref (G_OBJECT (nav_dialog->shell), - (GWeakNotify) g_free, - nav_dialog); - - /* the 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); - - nav_dialog->preview = nav_dialog_create_preview (nav_dialog, - shell->gdisp->gimage); - gtk_container_add (GTK_CONTAINER (frame), nav_dialog->preview); - gtk_widget_show (nav_dialog->preview); - - nav_dialog_update_marker (nav_dialog); - - /* the zoom scale */ - - nav_dialog->zoom_adjustment = - gtk_adjustment_new (0.0, -15.0, 16.0, 1.0, 1.0, 1.0); - - g_signal_connect (G_OBJECT (nav_dialog->zoom_adjustment), "value_changed", - G_CALLBACK (nav_dialog_zoom_adj_changed), - nav_dialog); - - 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_end (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), hscale, - FALSE, FALSE, 0); - gtk_widget_show (hscale); - - /* the zoom buttons */ - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (nav_dialog->shell)->vbox), hbox, - FALSE, FALSE, 0); - gtk_widget_show (hbox); - - button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - 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); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (nav_dialog_zoom_out), - nav_dialog); - - /* user zoom ratio */ - g_snprintf (scale_str, sizeof (scale_str), "%d:%d", - SCALEDEST (nav_dialog->disp_shell->gdisp), - SCALESRC (nav_dialog->disp_shell->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); - - button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); - - 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); - - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (nav_dialog_zoom_in), - nav_dialog); - - return nav_dialog; -} - -void -nav_dialog_create_popup (GimpDisplayShell *shell, - GtkWidget *widget, - gint button_x, - gint button_y) -{ - NavigationDialog *nav_dialog; - GimpNavigationPreview *preview; - gint x, y; - gint x_org, y_org; - gint scr_w, scr_h; - - if (! shell->nav_popup) - { - GtkWidget *frame; - GtkWidget *preview_frame; - - shell->nav_popup = nav_dialog = nav_dialog_new (shell); - - nav_dialog->shell = gtk_window_new (GTK_WINDOW_POPUP); - - g_object_weak_ref (G_OBJECT (nav_dialog->shell), - (GWeakNotify) g_free, - nav_dialog); - - 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); - - preview_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (preview_frame), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (frame), preview_frame); - gtk_widget_show (preview_frame); - - nav_dialog->preview = nav_dialog_create_preview (nav_dialog, - shell->gdisp->gimage); - gtk_container_add (GTK_CONTAINER (preview_frame), nav_dialog->preview); - gtk_widget_show (nav_dialog->preview); - - g_signal_connect (G_OBJECT (nav_dialog->preview), "button_release_event", - G_CALLBACK (nav_dialog_button_release), - nav_dialog); - } - else - { - nav_dialog = shell->nav_popup; - - gtk_widget_hide (nav_dialog->shell); - } - - nav_dialog_update_marker (nav_dialog); - - preview = GIMP_NAVIGATION_PREVIEW (nav_dialog->preview); - - /* 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 + button_x - - preview->p_x - - ((preview->p_width - BORDER_PEN_WIDTH + 1) * 0.5) - 2); - - y = (y_org + button_y - - preview->p_y - - ((preview->p_height - 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 + preview->p_width > scr_w) ? scr_w - preview->p_width - 2 : x; - y = (y + preview->p_height > scr_h) ? scr_h - preview->p_height - 2 : y; - - gtk_window_move (GTK_WINDOW (nav_dialog->shell), x, y); - gtk_widget_show (nav_dialog->shell); - - gdk_flush (); - - /* fill in then grab pointer */ - preview->motion_offset_x = - (preview->p_width - BORDER_PEN_WIDTH + 1) * 0.5; - - preview->motion_offset_y = - (preview->p_height - BORDER_PEN_WIDTH + 1) * 0.5; - - gimp_navigation_preview_grab_pointer (preview); -} - -void -nav_dialog_free (GimpDisplayShell *del_shell, - NavigationDialog *nav_dialog) -{ - /* So this functions works both ways.. - * it will come in here with nav_dialog == null - * if the auto mode is on... - */ - - if (nav_dialog) - { - gtk_widget_destroy (nav_dialog->shell); - } - else if (nav_window_auto) - { - GimpDisplay *gdisp = NULL; - GList *list; - - /* Only freeze if we are displaying the image we have deleted */ - if (nav_window_auto->disp_shell != del_shell) - return; - - for (list = GIMP_LIST (the_gimp->images)->list; - list; - list = g_list_next (list)) - { - gdisp = gdisplays_check_valid (NULL, GIMP_IMAGE (list->data)); - - if (gdisp) - break; - } - - if (gdisp) - { - nav_dialog_display_changed (NULL, gdisp, nav_window_auto); - } - else - { - /* Clear window and freeze */ - nav_window_auto->frozen = TRUE; - gtk_window_set_title (GTK_WINDOW (nav_window_auto->shell), - _("Navigation: No Image")); - - gtk_widget_set_sensitive (nav_window_auto->shell, FALSE); - nav_window_auto->disp_shell = NULL; - gtk_widget_hide (GTK_WIDGET (nav_window_auto->shell)); - } - } -} - -void -nav_dialog_show (NavigationDialog *nav_dialog) -{ - g_return_if_fail (nav_dialog != NULL); - - if (! GTK_WIDGET_VISIBLE (nav_dialog->shell)) - { - gtk_widget_show (nav_dialog->shell); - } - else - { - gdk_window_raise (nav_dialog->shell->window); - } -} - -void -nav_dialog_show_auto (Gimp *gimp) -{ - GimpContext *context; - GimpDisplay *gdisp; - - g_return_if_fail (GIMP_IS_GIMP (gimp)); - - context = gimp_get_user_context (gimp); - - gdisp = gimp_context_get_display (context); - - if (! gdisp) - return; - - if (! nav_window_auto) - { - nav_window_auto = nav_dialog_create (GIMP_DISPLAY_SHELL (gdisp->shell)); - - g_signal_connect (G_OBJECT (context), "display_changed", - G_CALLBACK (nav_dialog_display_changed), - nav_window_auto); - } - - nav_dialog_show (nav_window_auto); - - gtk_widget_set_sensitive (nav_window_auto->shell, TRUE); - - nav_window_auto->frozen = FALSE; -} - -void -nav_dialog_update (NavigationDialog *nav_dialog) -{ - /* So this functions works both ways.. - * it will come in here with info_win == null - * if the auto mode is on... - */ - - if (! nav_dialog) - { - if (nav_window_auto && ! nav_window_auto->frozen) - { - nav_dialog_update (nav_window_auto); - } - - return; - } - - if (! GTK_WIDGET_VISIBLE (nav_dialog->shell)) - return; - - if (nav_dialog->zoom_label) - { - gchar scale_str[MAX_SCALE_BUF]; - - /* Update the zoom scale string */ - g_snprintf (scale_str, sizeof (scale_str), "%d:%d", - SCALEDEST (nav_dialog->disp_shell->gdisp), - SCALESRC (nav_dialog->disp_shell->gdisp)); - - gtk_label_set_text (GTK_LABEL (nav_dialog->zoom_label), scale_str); - } - - if (nav_dialog->zoom_adjustment) - { - GtkAdjustment *adj; - gdouble f; - gdouble val; - - adj = GTK_ADJUSTMENT (nav_dialog->zoom_adjustment); - - f = (((gdouble) SCALEDEST (nav_dialog->disp_shell->gdisp)) / - ((gdouble) SCALESRC (nav_dialog->disp_shell->gdisp))); - - if (f < 1.0) - val = -1.0 / f; - else - val = f; - - if (abs ((gint) adj->value) != (gint) (val - 1) && - ! nav_dialog->block_adj_sig) - { - adj->value = val; - - gtk_adjustment_changed (GTK_ADJUSTMENT (nav_dialog->zoom_adjustment)); - } - } - - nav_dialog_update_marker (nav_dialog); -} - -void -nav_dialog_preview_resized (NavigationDialog *nav_dialog) -{ - if (! nav_dialog) - return; -} - - -/* private functions */ - -static NavigationDialog * -nav_dialog_new (GimpDisplayShell *shell) -{ - NavigationDialog *nav_dialog; - - nav_dialog = g_new0 (NavigationDialog, 1); - - nav_dialog->shell = NULL; - nav_dialog->preview = NULL; - nav_dialog->zoom_label = NULL; - nav_dialog->zoom_adjustment = NULL; - nav_dialog->disp_shell = shell; - - nav_dialog->block_adj_sig = FALSE; - nav_dialog->frozen = FALSE; - - return nav_dialog; -} - -static gchar * -nav_dialog_title (GimpDisplayShell *shell) -{ - gchar *basename; - gchar *title; - - basename = file_utils_uri_to_utf8_basename (gimp_image_get_uri (shell->gdisp->gimage)); - - title = g_strdup_printf (_("Navigation: %s-%d.%d"), - basename, - gimp_image_get_ID (shell->gdisp->gimage), - shell->gdisp->instance); - - g_free (basename); - - return title; -} - -static GtkWidget * -nav_dialog_create_preview (NavigationDialog *nav_dialog, - GimpImage *gimage) -{ - GtkWidget *preview; - - preview = gimp_navigation_preview_new (gimage, gimprc.nav_preview_size); - - g_signal_connect (G_OBJECT (preview), "marker_changed", - G_CALLBACK (nav_dialog_marker_changed), - nav_dialog); - 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); - - return preview; -} - -static void -nav_dialog_update_marker (NavigationDialog *nav_dialog) -{ - GimpImage *gimage; - gdouble xratio; - gdouble yratio; /* Screen res ratio */ - - /* Calculate preview size */ - gimage = nav_dialog->disp_shell->gdisp->gimage; - - xratio = SCALEFACTOR_X (nav_dialog->disp_shell->gdisp); - yratio = SCALEFACTOR_Y (nav_dialog->disp_shell->gdisp); - - if (GIMP_PREVIEW (nav_dialog->preview)->dot_for_dot != - nav_dialog->disp_shell->gdisp->dot_for_dot) - gimp_preview_set_dot_for_dot (GIMP_PREVIEW (nav_dialog->preview), - nav_dialog->disp_shell->gdisp->dot_for_dot); - - gimp_navigation_preview_set_marker - (GIMP_NAVIGATION_PREVIEW (nav_dialog->preview), - RINT (nav_dialog->disp_shell->offset_x / xratio), - RINT (nav_dialog->disp_shell->offset_y / yratio), - RINT (nav_dialog->disp_shell->disp_width / xratio), - RINT (nav_dialog->disp_shell->disp_height / yratio)); -} - -static void -nav_dialog_close_callback (GtkWidget *widget, - NavigationDialog *nav_dialog) -{ - gtk_widget_hide (nav_dialog->shell); -} - -static void -nav_dialog_marker_changed (GimpNavigationPreview *nav_preview, - gint x, - gint y, - NavigationDialog *nav_dialog) -{ - gdouble xratio; - gdouble yratio; - gint xoffset; - gint yoffset; - - xratio = SCALEFACTOR_X (nav_dialog->disp_shell->gdisp); - yratio = SCALEFACTOR_Y (nav_dialog->disp_shell->gdisp); - - xoffset = x * xratio - nav_dialog->disp_shell->offset_x; - yoffset = y * yratio - nav_dialog->disp_shell->offset_y; - - gimp_display_shell_scroll (nav_dialog->disp_shell, xoffset, yoffset); -} - -static void -nav_dialog_zoom (GimpNavigationPreview *nav_preview, - GimpZoomType direction, - NavigationDialog *nav_dialog) -{ - gimp_display_shell_scale (nav_dialog->disp_shell, direction); -} - -static void -nav_dialog_scroll (GimpNavigationPreview *nav_preview, - GdkScrollDirection direction, - NavigationDialog *nav_dialog) -{ - GtkAdjustment *adj = NULL; - gdouble value; - - switch (direction) - { - case GDK_SCROLL_LEFT: - case GDK_SCROLL_RIGHT: - adj = nav_dialog->disp_shell->hsbdata; - break; - - case GDK_SCROLL_UP: - case GDK_SCROLL_DOWN: - adj = nav_dialog->disp_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 gboolean -nav_dialog_button_release (GtkWidget *widget, - GdkEventButton *bevent, - NavigationDialog *nav_dialog) -{ - if (bevent->button == 1) - { - gtk_widget_hide (nav_dialog->shell); - } - - return FALSE; -} - -static void -nav_dialog_zoom_in (GtkWidget *widget, - NavigationDialog *nav_dialog) -{ - gimp_display_shell_scale (nav_dialog->disp_shell, GIMP_ZOOM_IN); -} - -static void -nav_dialog_zoom_out (GtkWidget *widget, - NavigationDialog *nav_dialog) -{ - gimp_display_shell_scale (nav_dialog->disp_shell, GIMP_ZOOM_OUT); -} - -static void -nav_dialog_zoom_adj_changed (GtkAdjustment *adj, - NavigationDialog *nav_dialog) -{ - gint scalesrc; - gint scaledest; - - if (adj->value < 0.0) - { - scalesrc = abs ((gint) adj->value - 1); - scaledest = 1; - } - else - { - scaledest = abs ((gint) adj->value + 1); - scalesrc = 1; - } - - nav_dialog->block_adj_sig = TRUE; - gimp_display_shell_scale (nav_dialog->disp_shell, - (scaledest * 100) + scalesrc); - nav_dialog->block_adj_sig = FALSE; -} - -static void -nav_dialog_display_changed (GimpContext *context, - GimpDisplay *gdisp, - NavigationDialog *nav_dialog) -{ - GimpDisplay *old_gdisp = NULL; - GimpImage *gimage; - gchar *title; - - if (nav_dialog->disp_shell) - old_gdisp = nav_dialog->disp_shell->gdisp; - - if (gdisp == old_gdisp || ! gdisp) - return; - - gtk_widget_set_sensitive (nav_window_auto->shell, TRUE); - - nav_dialog->frozen = FALSE; - - title = nav_dialog_title (GIMP_DISPLAY_SHELL (gdisp->shell)); - - gtk_window_set_title (GTK_WINDOW (nav_dialog->shell), title); - - g_free (title); - - gimage = gdisp->gimage; - - if (gimage && gimp_container_have (context->gimp->images, - GIMP_OBJECT (gimage))) - { - nav_dialog->disp_shell = GIMP_DISPLAY_SHELL (gdisp->shell); - - gimp_preview_set_viewable (GIMP_PREVIEW (nav_dialog->preview), - GIMP_VIEWABLE (gdisp->gimage)); - - nav_dialog_update (nav_dialog); - } -} diff --git a/app/nav_window.h b/app/nav_window.h deleted file mode 100644 index d81b8fe097..0000000000 --- a/app/nav_window.h +++ /dev/null @@ -1,39 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * 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 __NAV_WINDOW_H__ -#define __NAV_WINDOW_H__ - - -NavigationDialog * nav_dialog_create (GimpDisplayShell *shell); -void nav_dialog_create_popup (GimpDisplayShell *shell, - GtkWidget *widget, - gint button_x, - gint button_y); -void nav_dialog_free (GimpDisplayShell *del_shell, - NavigationDialog *nav_dialog); - -void nav_dialog_show (NavigationDialog *nav_dialog); -void nav_dialog_show_auto (Gimp *gimp); - -void nav_dialog_update (NavigationDialog *nav_dialog); -void nav_dialog_preview_resized (NavigationDialog *nav_dialog); - - -#endif /* __NAV_WINDOW_H__ */ diff --git a/app/widgets/gimpbufferview.c b/app/widgets/gimpbufferview.c index 3829c52025..a587c4ae20 100644 --- a/app/widgets/gimpbufferview.c +++ b/app/widgets/gimpbufferview.c @@ -27,6 +27,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpbuffer.h" #include "core/gimpcontainer.h" #include "core/gimpcontext.h" diff --git a/app/widgets/gimpchannellistview.c b/app/widgets/gimpchannellistview.c index 632b5a0ca4..a857522aae 100644 --- a/app/widgets/gimpchannellistview.c +++ b/app/widgets/gimpchannellistview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" diff --git a/app/widgets/gimpchanneltreeview.c b/app/widgets/gimpchanneltreeview.c index 632b5a0ca4..a857522aae 100644 --- a/app/widgets/gimpchanneltreeview.c +++ b/app/widgets/gimpchanneltreeview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" diff --git a/app/widgets/gimpcolormapeditor.c b/app/widgets/gimpcolormapeditor.c index 1ee0ed4f9e..fb39633c28 100644 --- a/app/widgets/gimpcolormapeditor.c +++ b/app/widgets/gimpcolormapeditor.c @@ -36,6 +36,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpcontainer.h" #include "core/gimpimage.h" #include "core/gimpmarshal.h" diff --git a/app/widgets/gimpcomponentlistitem.c b/app/widgets/gimpcomponentlistitem.c index a392d2be4e..79db390f08 100644 --- a/app/widgets/gimpcomponentlistitem.c +++ b/app/widgets/gimpcomponentlistitem.c @@ -27,6 +27,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpimage.h" #include "core/gimpviewable.h" diff --git a/app/widgets/gimpdocumentview.c b/app/widgets/gimpdocumentview.c index 3e69218b01..56bfbc6212 100644 --- a/app/widgets/gimpdocumentview.c +++ b/app/widgets/gimpdocumentview.c @@ -29,6 +29,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpedit.h" diff --git a/app/widgets/gimpdrawablelistitem.c b/app/widgets/gimpdrawablelistitem.c index a9144a6a71..09c0efa6fe 100644 --- a/app/widgets/gimpdrawablelistitem.c +++ b/app/widgets/gimpdrawablelistitem.c @@ -32,6 +32,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpdrawable.h" #include "display/gimpdisplay-foreach.h" diff --git a/app/widgets/gimpdrawablelistview.c b/app/widgets/gimpdrawablelistview.c index ca98fe4e59..7841f9920c 100644 --- a/app/widgets/gimpdrawablelistview.c +++ b/app/widgets/gimpdrawablelistview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpdrawable.h" diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c index ca98fe4e59..7841f9920c 100644 --- a/app/widgets/gimpdrawabletreeview.c +++ b/app/widgets/gimpdrawabletreeview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpdrawable.h" diff --git a/app/widgets/gimpimagedock.c b/app/widgets/gimpimagedock.c index 9954bc6842..19561bff27 100644 --- a/app/widgets/gimpimagedock.c +++ b/app/widgets/gimpimagedock.c @@ -46,22 +46,25 @@ #define DEFAULT_MINIMAL_WIDTH 250 -static void gimp_image_dock_class_init (GimpImageDockClass *klass); -static void gimp_image_dock_init (GimpImageDock *dock); +static void gimp_image_dock_class_init (GimpImageDockClass *klass); +static void gimp_image_dock_init (GimpImageDock *dock); -static void gimp_image_dock_destroy (GtkObject *object); +static void gimp_image_dock_destroy (GtkObject *object); -static void gimp_image_dock_style_set (GtkWidget *widget, - GtkStyle *prev_style); +static void gimp_image_dock_style_set (GtkWidget *widget, + GtkStyle *prev_style); -static void gimp_image_dock_factory_image_changed (GimpContext *context, - GimpImage *gimage, - GimpDock *dock); -static void gimp_image_dock_image_changed (GimpContext *context, - GimpImage *gimage, - GimpDock *dock); -static void gimp_image_dock_auto_clicked (GtkWidget *widget, - GimpDock *dock); +static void gimp_image_dock_factory_display_changed (GimpContext *context, + GimpObject *gdisp, + GimpDock *dock); +static void gimp_image_dock_factory_image_changed (GimpContext *context, + GimpImage *gimage, + GimpDock *dock); +static void gimp_image_dock_image_changed (GimpContext *context, + GimpImage *gimage, + GimpDock *dock); +static void gimp_image_dock_auto_clicked (GtkWidget *widget, + GimpDock *dock); static GimpDockClass *parent_class = NULL; @@ -230,6 +233,10 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory, gimp_context_copy_property (dialog_factory->context, context, GIMP_CONTEXT_PROP_IMAGE); + g_signal_connect_object (G_OBJECT (dialog_factory->context), "display_changed", + G_CALLBACK (gimp_image_dock_factory_display_changed), + G_OBJECT (image_dock), + 0); g_signal_connect_object (G_OBJECT (dialog_factory->context), "image_changed", G_CALLBACK (gimp_image_dock_factory_image_changed), G_OBJECT (image_dock), @@ -278,6 +285,21 @@ gimp_image_dock_set_show_image_menu (GimpImageDock *image_dock, image_dock->show_image_menu = show ? TRUE : FALSE; } +static void +gimp_image_dock_factory_display_changed (GimpContext *context, + GimpObject *gdisp, + GimpDock *dock) +{ + GimpImageDock *image_dock; + + image_dock = GIMP_IMAGE_DOCK (dock); + + if (gdisp && image_dock->auto_follow_active) + { + gimp_context_set_display (dock->context, gdisp); + } +} + static void gimp_image_dock_factory_image_changed (GimpContext *context, GimpImage *gimage, @@ -289,6 +311,8 @@ gimp_image_dock_factory_image_changed (GimpContext *context, if (gimage && image_dock->auto_follow_active) { + /* won't do anything if we already set the display above + */ gimp_context_set_image (dock->context, gimage); } } @@ -333,11 +357,22 @@ gimp_image_dock_auto_clicked (GtkWidget *widget, if (image_dock->auto_follow_active) { - GimpImage *gimage; + GimpObject *gdisp; - gimage = gimp_context_get_image (dock->dialog_factory->context); + gdisp = gimp_context_get_display (dock->dialog_factory->context); - if (gimage) - gimp_context_set_image (dock->context, gimage); + if (gdisp) + { + gimp_context_set_display (dock->context, gdisp); + } + else + { + GimpImage *gimage; + + gimage = gimp_context_get_image (dock->dialog_factory->context); + + if (gimage) + gimp_context_set_image (dock->context, gimage); + } } } diff --git a/app/widgets/gimpitemlistitem.c b/app/widgets/gimpitemlistitem.c index dc9b0a3186..cc69b6bb97 100644 --- a/app/widgets/gimpitemlistitem.c +++ b/app/widgets/gimpitemlistitem.c @@ -32,6 +32,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpitem.h" #include "display/gimpdisplay-foreach.h" diff --git a/app/widgets/gimpitemlistview.c b/app/widgets/gimpitemlistview.c index f1ad74d9c9..cb2a35f379 100644 --- a/app/widgets/gimpitemlistview.c +++ b/app/widgets/gimpitemlistview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c index f1ad74d9c9..cb2a35f379 100644 --- a/app/widgets/gimpitemtreeview.c +++ b/app/widgets/gimpitemtreeview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" diff --git a/app/widgets/gimplayerlistitem.c b/app/widgets/gimplayerlistitem.c index 48f4e8d6d7..ce702bddb3 100644 --- a/app/widgets/gimplayerlistitem.c +++ b/app/widgets/gimplayerlistitem.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpdrawable.h" #include "core/gimpimage.h" #include "core/gimplayer.h" diff --git a/app/widgets/gimplayerlistview.c b/app/widgets/gimplayerlistview.c index 6648674260..4dba05b134 100644 --- a/app/widgets/gimplayerlistview.c +++ b/app/widgets/gimplayerlistview.c @@ -28,6 +28,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimplayer.h" diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c index 6648674260..4dba05b134 100644 --- a/app/widgets/gimplayertreeview.c +++ b/app/widgets/gimplayertreeview.c @@ -28,6 +28,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpcontainer.h" #include "core/gimpdrawable.h" #include "core/gimplayer.h" diff --git a/app/widgets/gimpmenudock.c b/app/widgets/gimpmenudock.c index 9954bc6842..19561bff27 100644 --- a/app/widgets/gimpmenudock.c +++ b/app/widgets/gimpmenudock.c @@ -46,22 +46,25 @@ #define DEFAULT_MINIMAL_WIDTH 250 -static void gimp_image_dock_class_init (GimpImageDockClass *klass); -static void gimp_image_dock_init (GimpImageDock *dock); +static void gimp_image_dock_class_init (GimpImageDockClass *klass); +static void gimp_image_dock_init (GimpImageDock *dock); -static void gimp_image_dock_destroy (GtkObject *object); +static void gimp_image_dock_destroy (GtkObject *object); -static void gimp_image_dock_style_set (GtkWidget *widget, - GtkStyle *prev_style); +static void gimp_image_dock_style_set (GtkWidget *widget, + GtkStyle *prev_style); -static void gimp_image_dock_factory_image_changed (GimpContext *context, - GimpImage *gimage, - GimpDock *dock); -static void gimp_image_dock_image_changed (GimpContext *context, - GimpImage *gimage, - GimpDock *dock); -static void gimp_image_dock_auto_clicked (GtkWidget *widget, - GimpDock *dock); +static void gimp_image_dock_factory_display_changed (GimpContext *context, + GimpObject *gdisp, + GimpDock *dock); +static void gimp_image_dock_factory_image_changed (GimpContext *context, + GimpImage *gimage, + GimpDock *dock); +static void gimp_image_dock_image_changed (GimpContext *context, + GimpImage *gimage, + GimpDock *dock); +static void gimp_image_dock_auto_clicked (GtkWidget *widget, + GimpDock *dock); static GimpDockClass *parent_class = NULL; @@ -230,6 +233,10 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory, gimp_context_copy_property (dialog_factory->context, context, GIMP_CONTEXT_PROP_IMAGE); + g_signal_connect_object (G_OBJECT (dialog_factory->context), "display_changed", + G_CALLBACK (gimp_image_dock_factory_display_changed), + G_OBJECT (image_dock), + 0); g_signal_connect_object (G_OBJECT (dialog_factory->context), "image_changed", G_CALLBACK (gimp_image_dock_factory_image_changed), G_OBJECT (image_dock), @@ -278,6 +285,21 @@ gimp_image_dock_set_show_image_menu (GimpImageDock *image_dock, image_dock->show_image_menu = show ? TRUE : FALSE; } +static void +gimp_image_dock_factory_display_changed (GimpContext *context, + GimpObject *gdisp, + GimpDock *dock) +{ + GimpImageDock *image_dock; + + image_dock = GIMP_IMAGE_DOCK (dock); + + if (gdisp && image_dock->auto_follow_active) + { + gimp_context_set_display (dock->context, gdisp); + } +} + static void gimp_image_dock_factory_image_changed (GimpContext *context, GimpImage *gimage, @@ -289,6 +311,8 @@ gimp_image_dock_factory_image_changed (GimpContext *context, if (gimage && image_dock->auto_follow_active) { + /* won't do anything if we already set the display above + */ gimp_context_set_image (dock->context, gimage); } } @@ -333,11 +357,22 @@ gimp_image_dock_auto_clicked (GtkWidget *widget, if (image_dock->auto_follow_active) { - GimpImage *gimage; + GimpObject *gdisp; - gimage = gimp_context_get_image (dock->dialog_factory->context); + gdisp = gimp_context_get_display (dock->dialog_factory->context); - if (gimage) - gimp_context_set_image (dock->context, gimage); + if (gdisp) + { + gimp_context_set_display (dock->context, gdisp); + } + else + { + GimpImage *gimage; + + gimage = gimp_context_get_image (dock->dialog_factory->context); + + if (gimage) + gimp_context_set_image (dock->context, gimage); + } } } diff --git a/app/widgets/gimpnavigationpreview.c b/app/widgets/gimpnavigationpreview.c index dc10104ee1..6715d13fc9 100644 --- a/app/widgets/gimpnavigationpreview.c +++ b/app/widgets/gimpnavigationpreview.c @@ -2,7 +2,10 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * GimpNavigationPreview Widget - * Copyright (C) 2001 Michael Natterer + * Copyright (C) 2001-2002 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas * * 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 @@ -165,6 +168,9 @@ gimp_navigation_preview_init (GimpNavigationPreview *preview) { GTK_WIDGET_SET_FLAGS (preview, GTK_CAN_FOCUS); + gtk_widget_add_events (GTK_WIDGET (preview), (GDK_POINTER_MOTION_MASK | + GDK_KEY_PRESS_MASK)); + preview->x = 0; preview->y = 0; preview->width = 0; @@ -245,6 +251,9 @@ gimp_navigation_preview_move_to (GimpNavigationPreview *nav_preview, preview = GIMP_PREVIEW (nav_preview); + if (! preview->viewable) + return; + tx = CLAMP (tx, 0, preview->width); ty = CLAMP (ty, 0, preview->height); @@ -286,7 +295,7 @@ gimp_navigation_preview_grab_pointer (GimpNavigationPreview *nav_preview) gtk_grab_add (widget); - cursor = gdk_cursor_new (GDK_CROSSHAIR); + cursor = gdk_cursor_new (GDK_FLEUR); gdk_pointer_grab (widget->window, TRUE, GDK_BUTTON_RELEASE_MASK | @@ -318,6 +327,8 @@ gimp_navigation_preview_button_press (GtkWidget *widget, ty > nav_preview->p_y && ty < (nav_preview->p_y + nav_preview->p_height))) { + GdkCursor *cursor; + nav_preview->motion_offset_x = nav_preview->p_width / 2; nav_preview->motion_offset_y = nav_preview->p_height / 2; @@ -325,6 +336,10 @@ gimp_navigation_preview_button_press (GtkWidget *widget, ty -= nav_preview->motion_offset_y; gimp_navigation_preview_move_to (nav_preview, tx, ty); + + cursor = gdk_cursor_new (GDK_FLEUR); + gdk_window_set_cursor (widget->window, cursor); + gdk_cursor_unref (cursor); } else { @@ -423,7 +438,34 @@ gimp_navigation_preview_motion_notify (GtkWidget *widget, nav_preview = GIMP_NAVIGATION_PREVIEW (widget); if (! nav_preview->has_grab) - return FALSE; + { + GdkCursor *cursor; + + if (nav_preview->p_x == 0 && + nav_preview->p_y == 0 && + nav_preview->p_width == GIMP_PREVIEW (widget)->width && + nav_preview->p_height == GIMP_PREVIEW (widget)->height) + { + gdk_window_set_cursor (widget->window, NULL); + return FALSE; + } + else if (mevent->x >= nav_preview->p_x && + mevent->y >= nav_preview->p_y && + mevent->x < nav_preview->p_x + nav_preview->p_width && + mevent->y < nav_preview->p_y + nav_preview->p_height) + { + cursor = gdk_cursor_new (GDK_FLEUR); + } + else + { + cursor = gdk_cursor_new (GDK_HAND2); + } + + gdk_window_set_cursor (widget->window, cursor); + gdk_cursor_unref (cursor); + + return FALSE; + } gdk_window_get_pointer (widget->window, &tx, &ty, &mask); @@ -532,16 +574,22 @@ gimp_navigation_preview_new (GimpImage *gimage, { GimpPreview *preview; - g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); + g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL); g_return_val_if_fail (size > 0 && size <= 256, NULL); preview = g_object_new (GIMP_TYPE_NAVIGATION_PREVIEW, NULL); preview->is_popup = TRUE; - gimp_preview_set_viewable (preview, GIMP_VIEWABLE (gimage)); - - gimp_preview_set_size (preview, size, 0); + if (gimage) + { + gimp_preview_set_viewable (preview, GIMP_VIEWABLE (gimage)); + gimp_preview_set_size (preview, size, 0); + } + else + { + preview->size = size; + } return GTK_WIDGET (preview); } diff --git a/app/widgets/gimpnavigationpreview.h b/app/widgets/gimpnavigationpreview.h index edc187b3c4..a71c682bb0 100644 --- a/app/widgets/gimpnavigationpreview.h +++ b/app/widgets/gimpnavigationpreview.h @@ -2,7 +2,10 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * GimpNavigationPreview Widget - * Copyright (C) 2001 Michael Natterer + * Copyright (C) 2001-2002 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas * * 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 diff --git a/app/widgets/gimpnavigationview.c b/app/widgets/gimpnavigationview.c index dc10104ee1..6715d13fc9 100644 --- a/app/widgets/gimpnavigationview.c +++ b/app/widgets/gimpnavigationview.c @@ -2,7 +2,10 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * GimpNavigationPreview Widget - * Copyright (C) 2001 Michael Natterer + * Copyright (C) 2001-2002 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas * * 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 @@ -165,6 +168,9 @@ gimp_navigation_preview_init (GimpNavigationPreview *preview) { GTK_WIDGET_SET_FLAGS (preview, GTK_CAN_FOCUS); + gtk_widget_add_events (GTK_WIDGET (preview), (GDK_POINTER_MOTION_MASK | + GDK_KEY_PRESS_MASK)); + preview->x = 0; preview->y = 0; preview->width = 0; @@ -245,6 +251,9 @@ gimp_navigation_preview_move_to (GimpNavigationPreview *nav_preview, preview = GIMP_PREVIEW (nav_preview); + if (! preview->viewable) + return; + tx = CLAMP (tx, 0, preview->width); ty = CLAMP (ty, 0, preview->height); @@ -286,7 +295,7 @@ gimp_navigation_preview_grab_pointer (GimpNavigationPreview *nav_preview) gtk_grab_add (widget); - cursor = gdk_cursor_new (GDK_CROSSHAIR); + cursor = gdk_cursor_new (GDK_FLEUR); gdk_pointer_grab (widget->window, TRUE, GDK_BUTTON_RELEASE_MASK | @@ -318,6 +327,8 @@ gimp_navigation_preview_button_press (GtkWidget *widget, ty > nav_preview->p_y && ty < (nav_preview->p_y + nav_preview->p_height))) { + GdkCursor *cursor; + nav_preview->motion_offset_x = nav_preview->p_width / 2; nav_preview->motion_offset_y = nav_preview->p_height / 2; @@ -325,6 +336,10 @@ gimp_navigation_preview_button_press (GtkWidget *widget, ty -= nav_preview->motion_offset_y; gimp_navigation_preview_move_to (nav_preview, tx, ty); + + cursor = gdk_cursor_new (GDK_FLEUR); + gdk_window_set_cursor (widget->window, cursor); + gdk_cursor_unref (cursor); } else { @@ -423,7 +438,34 @@ gimp_navigation_preview_motion_notify (GtkWidget *widget, nav_preview = GIMP_NAVIGATION_PREVIEW (widget); if (! nav_preview->has_grab) - return FALSE; + { + GdkCursor *cursor; + + if (nav_preview->p_x == 0 && + nav_preview->p_y == 0 && + nav_preview->p_width == GIMP_PREVIEW (widget)->width && + nav_preview->p_height == GIMP_PREVIEW (widget)->height) + { + gdk_window_set_cursor (widget->window, NULL); + return FALSE; + } + else if (mevent->x >= nav_preview->p_x && + mevent->y >= nav_preview->p_y && + mevent->x < nav_preview->p_x + nav_preview->p_width && + mevent->y < nav_preview->p_y + nav_preview->p_height) + { + cursor = gdk_cursor_new (GDK_FLEUR); + } + else + { + cursor = gdk_cursor_new (GDK_HAND2); + } + + gdk_window_set_cursor (widget->window, cursor); + gdk_cursor_unref (cursor); + + return FALSE; + } gdk_window_get_pointer (widget->window, &tx, &ty, &mask); @@ -532,16 +574,22 @@ gimp_navigation_preview_new (GimpImage *gimage, { GimpPreview *preview; - g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); + g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL); g_return_val_if_fail (size > 0 && size <= 256, NULL); preview = g_object_new (GIMP_TYPE_NAVIGATION_PREVIEW, NULL); preview->is_popup = TRUE; - gimp_preview_set_viewable (preview, GIMP_VIEWABLE (gimage)); - - gimp_preview_set_size (preview, size, 0); + if (gimage) + { + gimp_preview_set_viewable (preview, GIMP_VIEWABLE (gimage)); + gimp_preview_set_size (preview, size, 0); + } + else + { + preview->size = size; + } return GTK_WIDGET (preview); } diff --git a/app/widgets/gimpnavigationview.h b/app/widgets/gimpnavigationview.h index edc187b3c4..a71c682bb0 100644 --- a/app/widgets/gimpnavigationview.h +++ b/app/widgets/gimpnavigationview.h @@ -2,7 +2,10 @@ * Copyright (C) 1995 Spencer Kimball and Peter Mattis * * GimpNavigationPreview Widget - * Copyright (C) 2001 Michael Natterer + * Copyright (C) 2001-2002 Michael Natterer + * + * partly based on app/nav_window + * Copyright (C) 1999 Andy Thomas * * 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 diff --git a/app/widgets/gimppreview.c b/app/widgets/gimppreview.c index dbf1251bb0..3a54acff06 100644 --- a/app/widgets/gimppreview.c +++ b/app/widgets/gimppreview.c @@ -32,6 +32,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "base/temp-buf.h" #include "core/gimpmarshal.h" diff --git a/app/widgets/gimppreviewrenderer.c b/app/widgets/gimppreviewrenderer.c index dbf1251bb0..3a54acff06 100644 --- a/app/widgets/gimppreviewrenderer.c +++ b/app/widgets/gimppreviewrenderer.c @@ -32,6 +32,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "base/temp-buf.h" #include "core/gimpmarshal.h" diff --git a/app/widgets/gimpvectorslistview.c b/app/widgets/gimpvectorslistview.c index fbc7b60af5..a722679213 100644 --- a/app/widgets/gimpvectorslistview.c +++ b/app/widgets/gimpvectorslistview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" diff --git a/app/widgets/gimpvectorstreeview.c b/app/widgets/gimpvectorstreeview.c index fbc7b60af5..a722679213 100644 --- a/app/widgets/gimpvectorstreeview.c +++ b/app/widgets/gimpvectorstreeview.c @@ -33,6 +33,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "core/gimpchannel.h" #include "core/gimpcontainer.h" #include "core/gimpimage.h" diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c index dbf1251bb0..3a54acff06 100644 --- a/app/widgets/gimpview.c +++ b/app/widgets/gimpview.c @@ -32,6 +32,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "base/temp-buf.h" #include "core/gimpmarshal.h" diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c index dbf1251bb0..3a54acff06 100644 --- a/app/widgets/gimpviewrenderer.c +++ b/app/widgets/gimpviewrenderer.c @@ -32,6 +32,9 @@ #include "widgets-types.h" +#warning FIXME #include "display/display-types.h" +#include "display/display-types.h" + #include "base/temp-buf.h" #include "core/gimpmarshal.h" diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h index 368e7afcaa..397774cc93 100644 --- a/app/widgets/widgets-types.h +++ b/app/widgets/widgets-types.h @@ -24,8 +24,6 @@ #include "core/core-types.h" -#include "display/display-types.h" - #include "widgets/widgets-enums.h" diff --git a/libgimpproxy/gimpproxytypes.h b/libgimpproxy/gimpproxytypes.h index 17fdbd5090..e1fef882e7 100644 --- a/libgimpproxy/gimpproxytypes.h +++ b/libgimpproxy/gimpproxytypes.h @@ -161,8 +161,8 @@ typedef enum /*< skip >*/ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -typedef struct _GimpDisplay GimpDisplay; /*< proxy-resume >*/ -typedef struct _GimpDisplayShell GimpDisplayShell; +typedef struct _GimpDisplay GimpDisplay; /*< proxy-resume >*/ +typedef struct _GimpDisplayShell GimpDisplayShell; #endif /* __GIMP_PROXY_TYPES_H__ */