Ported GimpNavigationView to use actions for its buttons:
2004-09-26 Michael Natterer <mitch@gimp.org> Ported GimpNavigationView to use actions for its buttons: * app/menus/menus.c (menus_init): register a <GimpNaviagaionEditor> UI manager containing the "view" action group. * app/actions/actions.c (action_data_get_foo): handle "data" being a GimpNavigationEditor. * app/actions/view-actions.c (view_actions): added tooltips for the actions used in the editor. (view_actions_update): use action_data_get_display() instead of checking the type of "data" manually. * app/widgets/gimpeditor.c (gimp_editor_add_action_button): use a GtkToggleButton instead of GimpButton for GtkToggleActions. * app/display/gimpnavigationeditor.[ch]: added a GimpMenuFactory parameter to the public constructor and removed all other parameters. Simplified gimp_navigation_editor_new_private() and use gimp_editor_add_action_button() instead of just add_button() for creating the buttons. Made gimp_navigation_view_set_shell() private. Update the UI manager when the shell zooms or scrolls. * app/dialogs/dialogs-constructors.c (dialogs_navigation_view_new): pass the menu_factory to gimp_navigation_editor_new(). Removed #includes which are not needed any more.
This commit is contained in:
parent
5c6e0c8e40
commit
b4ea222c23
8 changed files with 221 additions and 248 deletions
31
ChangeLog
31
ChangeLog
|
|
@ -1,3 +1,34 @@
|
|||
2004-09-26 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Ported GimpNavigationView to use actions for its buttons:
|
||||
|
||||
* app/menus/menus.c (menus_init): register a <GimpNaviagaionEditor>
|
||||
UI manager containing the "view" action group.
|
||||
|
||||
* app/actions/actions.c (action_data_get_foo): handle "data" being
|
||||
a GimpNavigationEditor.
|
||||
|
||||
* app/actions/view-actions.c (view_actions): added tooltips for
|
||||
the actions used in the editor.
|
||||
|
||||
(view_actions_update): use action_data_get_display() instead of
|
||||
checking the type of "data" manually.
|
||||
|
||||
* app/widgets/gimpeditor.c (gimp_editor_add_action_button): use
|
||||
a GtkToggleButton instead of GimpButton for GtkToggleActions.
|
||||
|
||||
* app/display/gimpnavigationeditor.[ch]: added a GimpMenuFactory
|
||||
parameter to the public constructor and removed all other
|
||||
parameters. Simplified gimp_navigation_editor_new_private() and
|
||||
use gimp_editor_add_action_button() instead of just add_button()
|
||||
for creating the buttons. Made gimp_navigation_view_set_shell()
|
||||
private. Update the UI manager when the shell zooms or scrolls.
|
||||
|
||||
* app/dialogs/dialogs-constructors.c (dialogs_navigation_view_new):
|
||||
pass the menu_factory to gimp_navigation_editor_new().
|
||||
|
||||
Removed #includes which are not needed any more.
|
||||
|
||||
2004-09-26 DindinX <dindinx@gimp.org>
|
||||
|
||||
* plug-ins/common/exchange.c: use the same preview as in all other
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
#include "display/gimpnavigationeditor.h"
|
||||
|
||||
#include "dialogs/dialogs.h"
|
||||
|
||||
|
|
@ -234,6 +235,8 @@ action_data_get_gimp (gpointer data)
|
|||
return ((GimpItemTreeView *) data)->context->gimp;
|
||||
else if (GIMP_IS_IMAGE_EDITOR (data))
|
||||
return ((GimpImageEditor *) data)->context->gimp;
|
||||
else if (GIMP_IS_NAVIGATION_EDITOR (data))
|
||||
return ((GimpNavigationEditor *) data)->context->gimp;
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
return data;
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
|
@ -260,6 +263,8 @@ action_data_get_context (gpointer data)
|
|||
return gimp_container_view_get_context (((GimpContainerEditor *) data)->view);
|
||||
else if (GIMP_IS_IMAGE_EDITOR (data))
|
||||
return ((GimpImageEditor *) data)->context;
|
||||
else if (GIMP_IS_NAVIGATION_EDITOR (data))
|
||||
return ((GimpNavigationEditor *) data)->context;
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
return gimp_get_user_context (data);
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
|
@ -282,6 +287,8 @@ action_data_get_image (gpointer data)
|
|||
return ((GimpItemTreeView *) data)->gimage;
|
||||
else if (GIMP_IS_IMAGE_EDITOR (data))
|
||||
return ((GimpImageEditor *) data)->gimage;
|
||||
else if (GIMP_IS_NAVIGATION_EDITOR (data))
|
||||
return gimp_context_get_image (((GimpNavigationEditor *) data)->context);
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
return gimp_context_get_image (gimp_get_user_context (data));
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
|
@ -300,6 +307,8 @@ action_data_get_display (gpointer data)
|
|||
return data;
|
||||
else if (GIMP_IS_DISPLAY_SHELL (data))
|
||||
return ((GimpDisplayShell *) data)->gdisp;
|
||||
else if (GIMP_IS_NAVIGATION_EDITOR (data))
|
||||
return gimp_context_get_display (((GimpNavigationEditor *) data)->context);
|
||||
else if (GIMP_IS_GIMP (data))
|
||||
return gimp_context_get_display (gimp_get_user_context (data));
|
||||
else if (GIMP_IS_DOCK (data))
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include "display/gimpdisplayshell-render.h"
|
||||
#include "display/gimpdisplayshell-selection.h"
|
||||
|
||||
#include "actions.h"
|
||||
#include "view-actions.h"
|
||||
#include "view-commands.h"
|
||||
|
||||
|
|
@ -74,22 +75,26 @@ static GimpActionEntry view_actions[] =
|
|||
GIMP_HELP_FILE_CLOSE },
|
||||
|
||||
{ "view-zoom-out", GTK_STOCK_ZOOM_OUT,
|
||||
N_("Zoom _Out"), "minus", NULL,
|
||||
N_("Zoom _Out"), "minus",
|
||||
N_("Zoom out"),
|
||||
G_CALLBACK (view_zoom_out_cmd_callback),
|
||||
GIMP_HELP_VIEW_ZOOM_OUT },
|
||||
|
||||
{ "view-zoom-in", GTK_STOCK_ZOOM_IN,
|
||||
N_("Zoom _In"), "plus", NULL,
|
||||
N_("Zoom _In"), "plus",
|
||||
N_("Zoom in"),
|
||||
G_CALLBACK (view_zoom_in_cmd_callback),
|
||||
GIMP_HELP_VIEW_ZOOM_IN },
|
||||
|
||||
{ "view-zoom-fit-in", GTK_STOCK_ZOOM_FIT,
|
||||
N_("_Fit Image in Window"), "<control><shift>E", NULL,
|
||||
N_("_Fit Image in Window"), "<control><shift>E",
|
||||
N_("Fit image in window"),
|
||||
G_CALLBACK (view_zoom_fit_in_cmd_callback),
|
||||
GIMP_HELP_VIEW_ZOOM_FIT_IN },
|
||||
|
||||
{ "view-zoom-fit-to", GTK_STOCK_ZOOM_FIT,
|
||||
N_("Fit Image to Window"), NULL, NULL,
|
||||
N_("Fit Image to Window"), NULL,
|
||||
N_("Fit image to window"),
|
||||
G_CALLBACK (view_zoom_fit_to_cmd_callback),
|
||||
GIMP_HELP_VIEW_ZOOM_FIT_TO },
|
||||
|
||||
|
|
@ -108,8 +113,9 @@ static GimpActionEntry view_actions[] =
|
|||
G_CALLBACK (view_display_filters_cmd_callback),
|
||||
GIMP_HELP_DISPLAY_FILTER_DIALOG },
|
||||
|
||||
{ "view-shrink-wrap", NULL,
|
||||
N_("Shrink _Wrap"), "<control>E", NULL,
|
||||
{ "view-shrink-wrap", GTK_STOCK_ZOOM_FIT,
|
||||
N_("Shrink _Wrap"), "<control>E",
|
||||
N_("Shrink wrap"),
|
||||
G_CALLBACK (view_shrink_wrap_cmd_callback),
|
||||
GIMP_HELP_VIEW_SHRINK_WRAP },
|
||||
|
||||
|
|
@ -217,7 +223,8 @@ static GimpRadioActionEntry view_zoom_actions[] =
|
|||
GIMP_HELP_VIEW_ZOOM_IN },
|
||||
|
||||
{ "view-zoom-1-1", GTK_STOCK_ZOOM_100,
|
||||
N_("1:1 (100%)"), "1", NULL,
|
||||
N_("1:1 (100%)"), "1",
|
||||
N_("Zoom 1:1"),
|
||||
10000,
|
||||
GIMP_HELP_VIEW_ZOOM_100 },
|
||||
|
||||
|
|
@ -401,19 +408,11 @@ view_actions_update (GimpActionGroup *group,
|
|||
gboolean fullscreen = FALSE;
|
||||
gint n_screens = 1;
|
||||
|
||||
if (GIMP_IS_DISPLAY_SHELL (data))
|
||||
{
|
||||
shell = GIMP_DISPLAY_SHELL (data);
|
||||
gdisp = shell->gdisp;
|
||||
}
|
||||
else if (GIMP_IS_DISPLAY (data))
|
||||
{
|
||||
gdisp = GIMP_DISPLAY (data);
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
}
|
||||
gdisp = action_data_get_display (data);
|
||||
|
||||
if (gdisp)
|
||||
{
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
gimage = gdisp->gimage;
|
||||
|
||||
fullscreen = gimp_display_shell_get_fullscreen (shell);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "config/gimpdisplayconfig.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "widgets/gimpbrusheditor.h"
|
||||
#include "widgets/gimpbrushfactoryview.h"
|
||||
|
|
@ -67,8 +67,6 @@
|
|||
#include "widgets/gimpundoeditor.h"
|
||||
#include "widgets/gimpvectorstreeview.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
#include "display/gimpnavigationeditor.h"
|
||||
|
||||
#include "actions/channels-commands.h"
|
||||
|
|
@ -820,17 +818,9 @@ dialogs_navigation_view_new (GimpDialogFactory *factory,
|
|||
GimpContext *context,
|
||||
gint preview_size)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpDisplayShell *shell = NULL;
|
||||
GtkWidget *view;
|
||||
GtkWidget *view;
|
||||
|
||||
gdisp = gimp_context_get_display (context);
|
||||
|
||||
if (gdisp)
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
view = gimp_navigation_editor_new (shell,
|
||||
GIMP_DISPLAY_CONFIG (context->gimp->config));
|
||||
view = gimp_navigation_editor_new (factory->menu_factory);
|
||||
|
||||
return dialogs_dockable_new (view,
|
||||
_("Navigation"), _("Display Navigation"),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@
|
|||
|
||||
#include "widgets/gimpdocked.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpmenufactory.h"
|
||||
#include "widgets/gimpnavigationview.h"
|
||||
#include "widgets/gimpuimanager.h"
|
||||
#include "widgets/gimpviewrenderer.h"
|
||||
|
||||
#include "gimpdisplay.h"
|
||||
|
|
@ -56,57 +58,46 @@
|
|||
static void gimp_navigation_editor_class_init (GimpNavigationEditorClass *klass);
|
||||
static void gimp_navigation_editor_init (GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_docked_iface_init (GimpDockedInterface *docked_iface);
|
||||
static void gimp_navigation_editor_set_context (GimpDocked *docked,
|
||||
GimpContext *context);
|
||||
static void gimp_navigation_editor_docked_iface_init (GimpDockedInterface *docked_iface);
|
||||
static void gimp_navigation_editor_set_context (GimpDocked *docked,
|
||||
GimpContext *context);
|
||||
|
||||
static void gimp_navigation_editor_destroy (GtkObject *object);
|
||||
static void gimp_navigation_editor_destroy (GtkObject *object);
|
||||
|
||||
static GtkWidget * gimp_navigation_editor_new_private (GimpDisplayShell *shell,
|
||||
GimpDisplayConfig *config,
|
||||
gboolean popup);
|
||||
static GtkWidget * gimp_navigation_editor_new_private (GimpMenuFactory *menu_factory,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
static gboolean gimp_navigation_editor_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_navigation_editor_marker_changed (GimpNavigationView *view,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_zoom (GimpNavigationView *view,
|
||||
GimpZoomType direction,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_scroll (GimpNavigationView *view,
|
||||
GdkScrollDirection direction,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_set_shell (GimpNavigationEditor *view,
|
||||
GimpDisplayShell *shell);
|
||||
static gboolean gimp_navigation_editor_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_navigation_editor_marker_changed (GimpNavigationView *view,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_zoom (GimpNavigationView *view,
|
||||
GimpZoomType direction,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_scroll (GimpNavigationView *view,
|
||||
GdkScrollDirection direction,
|
||||
GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
|
||||
GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_zoom_out_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_zoom_in_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_zoom_100_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_zoom_fit_in_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_zoom_fit_to_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shrink_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_update_marker (GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_update_marker (GimpNavigationEditor *editor);
|
||||
|
||||
|
||||
static GimpEditorClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_navigation_editor_get_type (void)
|
||||
{
|
||||
|
|
@ -147,11 +138,7 @@ gimp_navigation_editor_get_type (void)
|
|||
static void
|
||||
gimp_navigation_editor_class_init (GimpNavigationEditorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkObjectClass *gtk_object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
gtk_object_class = GTK_OBJECT_CLASS (klass);
|
||||
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
|
|
@ -255,63 +242,9 @@ gimp_navigation_editor_destroy (GtkObject *object)
|
|||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_navigation_editor_new (GimpDisplayShell *shell,
|
||||
GimpDisplayConfig *config)
|
||||
gimp_navigation_editor_new (GimpMenuFactory *menu_factory)
|
||||
{
|
||||
return gimp_navigation_editor_new_private (shell, config, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_NAVIGATION_EDITOR (editor));
|
||||
g_return_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
if (shell == editor->shell)
|
||||
return;
|
||||
|
||||
if (editor->shell)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_scaled,
|
||||
editor);
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_scrolled,
|
||||
editor);
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_reconnect,
|
||||
editor);
|
||||
}
|
||||
else if (shell)
|
||||
{
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||
}
|
||||
|
||||
editor->shell = shell;
|
||||
|
||||
if (editor->shell)
|
||||
{
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view),
|
||||
GIMP_VIEWABLE (shell->gdisp->gimage));
|
||||
|
||||
g_signal_connect (editor->shell, "scaled",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_scaled),
|
||||
editor);
|
||||
g_signal_connect (editor->shell, "scrolled",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_scrolled),
|
||||
editor);
|
||||
g_signal_connect (editor->shell, "reconnect",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_reconnect),
|
||||
editor);
|
||||
|
||||
gimp_navigation_editor_shell_scaled (editor->shell, editor);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
|
||||
}
|
||||
return gimp_navigation_editor_new_private (menu_factory, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -331,8 +264,7 @@ gimp_navigation_editor_popup (GimpDisplayShell *shell,
|
|||
|
||||
if (! shell->nav_popup)
|
||||
{
|
||||
GimpDisplayConfig *config;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *frame;
|
||||
|
||||
shell->nav_popup = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
|
||||
|
|
@ -341,12 +273,9 @@ gimp_navigation_editor_popup (GimpDisplayShell *shell,
|
|||
gtk_container_add (GTK_CONTAINER (shell->nav_popup), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
|
||||
|
||||
editor =
|
||||
GIMP_NAVIGATION_EDITOR (gimp_navigation_editor_new_private (shell,
|
||||
config,
|
||||
TRUE));
|
||||
GIMP_NAVIGATION_EDITOR (gimp_navigation_editor_new_private (NULL,
|
||||
shell));
|
||||
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (editor));
|
||||
gtk_widget_show (GTK_WIDGET (editor));
|
||||
|
||||
|
|
@ -415,30 +344,41 @@ gimp_navigation_editor_popup (GimpDisplayShell *shell,
|
|||
/* private functions */
|
||||
|
||||
static GtkWidget *
|
||||
gimp_navigation_editor_new_private (GimpDisplayShell *shell,
|
||||
GimpDisplayConfig *config,
|
||||
gboolean popup)
|
||||
gimp_navigation_editor_new_private (GimpMenuFactory *menu_factory,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpNavigationEditor *editor;
|
||||
|
||||
g_return_val_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY_CONFIG (config), NULL);
|
||||
g_return_val_if_fail (! popup || (popup && shell), NULL);
|
||||
g_return_val_if_fail (menu_factory == NULL ||
|
||||
GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
||||
g_return_val_if_fail (shell == NULL || GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
||||
g_return_val_if_fail (menu_factory || shell, NULL);
|
||||
|
||||
editor = g_object_new (GIMP_TYPE_NAVIGATION_EDITOR, NULL);
|
||||
|
||||
if (popup)
|
||||
if (shell)
|
||||
{
|
||||
GimpView *view = GIMP_VIEW (editor->view);
|
||||
GimpDisplayConfig *config;
|
||||
GimpView *view;
|
||||
|
||||
editor = g_object_new (GIMP_TYPE_NAVIGATION_EDITOR, NULL);
|
||||
|
||||
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
|
||||
view = GIMP_VIEW (editor->view);
|
||||
|
||||
gimp_view_renderer_set_size (view->renderer,
|
||||
config->nav_preview_size * 3,
|
||||
view->renderer->border_width);
|
||||
|
||||
gimp_navigation_editor_set_shell (editor, shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *hscale;
|
||||
|
||||
editor = g_object_new (GIMP_TYPE_NAVIGATION_EDITOR,
|
||||
"menu-factory", menu_factory,
|
||||
"menu-identifier", "<NavigationEditor>",
|
||||
NULL);
|
||||
|
||||
gtk_widget_set_size_request (editor->view,
|
||||
GIMP_VIEW_SIZE_HUGE,
|
||||
GIMP_VIEW_SIZE_HUGE);
|
||||
|
|
@ -447,52 +387,28 @@ gimp_navigation_editor_new_private (GimpDisplayShell *shell,
|
|||
/* the editor buttons */
|
||||
|
||||
editor->zoom_out_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_ZOOM_OUT, _("Zoom out"),
|
||||
GIMP_HELP_VIEW_ZOOM_OUT,
|
||||
G_CALLBACK (gimp_navigation_editor_zoom_out_clicked),
|
||||
NULL,
|
||||
editor);
|
||||
gimp_editor_add_action_button (GIMP_EDITOR (editor), "view",
|
||||
"view-zoom-out", NULL);
|
||||
|
||||
editor->zoom_in_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_ZOOM_IN, _("Zoom in"),
|
||||
GIMP_HELP_VIEW_ZOOM_IN,
|
||||
G_CALLBACK (gimp_navigation_editor_zoom_in_clicked),
|
||||
NULL,
|
||||
editor);
|
||||
gimp_editor_add_action_button (GIMP_EDITOR (editor), "view",
|
||||
"view-zoom-in", NULL);
|
||||
|
||||
editor->zoom_100_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_ZOOM_100, _("Zoom 1:1"),
|
||||
GIMP_HELP_VIEW_ZOOM_100,
|
||||
G_CALLBACK (gimp_navigation_editor_zoom_100_clicked),
|
||||
NULL,
|
||||
editor);
|
||||
gimp_editor_add_action_button (GIMP_EDITOR (editor), "view",
|
||||
"view-zoom-1-1", NULL);
|
||||
|
||||
editor->zoom_fit_in_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_ZOOM_FIT, _("Fit Image in Window"),
|
||||
GIMP_HELP_VIEW_ZOOM_FIT_IN,
|
||||
G_CALLBACK (gimp_navigation_editor_zoom_fit_in_clicked),
|
||||
NULL,
|
||||
editor);
|
||||
gimp_editor_add_action_button (GIMP_EDITOR (editor), "view",
|
||||
"view-zoom-fit-in", NULL);
|
||||
|
||||
editor->zoom_fit_to_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_ZOOM_FIT, _("Fit Image to Window"),
|
||||
GIMP_HELP_VIEW_ZOOM_FIT_TO,
|
||||
G_CALLBACK (gimp_navigation_editor_zoom_fit_to_clicked),
|
||||
NULL,
|
||||
editor);
|
||||
gimp_editor_add_action_button (GIMP_EDITOR (editor), "view",
|
||||
"view-zoom-fit-to", NULL);
|
||||
|
||||
editor->shrink_wrap_button =
|
||||
gimp_editor_add_button (GIMP_EDITOR (editor),
|
||||
GTK_STOCK_ZOOM_FIT, _("Shrink Wrap"),
|
||||
GIMP_HELP_VIEW_SHRINK_WRAP,
|
||||
G_CALLBACK (gimp_navigation_editor_shrink_clicked),
|
||||
NULL,
|
||||
editor);
|
||||
gimp_editor_add_action_button (GIMP_EDITOR (editor), "view",
|
||||
"view-shrink-wrap", NULL);
|
||||
|
||||
/* the zoom scale */
|
||||
|
||||
|
|
@ -527,15 +443,69 @@ gimp_navigation_editor_new_private (GimpDisplayShell *shell,
|
|||
}
|
||||
}
|
||||
|
||||
if (shell)
|
||||
gimp_navigation_editor_set_shell (editor, shell);
|
||||
|
||||
gimp_view_renderer_set_background (GIMP_VIEW (editor->view)->renderer,
|
||||
GIMP_STOCK_TEXTURE);
|
||||
|
||||
return GTK_WIDGET (editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_NAVIGATION_EDITOR (editor));
|
||||
g_return_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
if (shell == editor->shell)
|
||||
return;
|
||||
|
||||
if (editor->shell)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_scaled,
|
||||
editor);
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_scrolled,
|
||||
editor);
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_reconnect,
|
||||
editor);
|
||||
}
|
||||
else if (shell)
|
||||
{
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
|
||||
}
|
||||
|
||||
editor->shell = shell;
|
||||
|
||||
if (editor->shell)
|
||||
{
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view),
|
||||
GIMP_VIEWABLE (shell->gdisp->gimage));
|
||||
|
||||
g_signal_connect (editor->shell, "scaled",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_scaled),
|
||||
editor);
|
||||
g_signal_connect (editor->shell, "scrolled",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_scrolled),
|
||||
editor);
|
||||
g_signal_connect (editor->shell, "reconnect",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_reconnect),
|
||||
editor);
|
||||
|
||||
gimp_navigation_editor_shell_scaled (editor->shell, editor);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
|
||||
}
|
||||
|
||||
if (GIMP_EDITOR (editor)->ui_manager)
|
||||
gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager,
|
||||
GIMP_EDITOR (editor)->popup_data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_navigation_editor_button_release (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
|
|
@ -639,54 +609,6 @@ gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
|
|||
pow (2.0, adj->value));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_zoom_out_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
if (editor->shell)
|
||||
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_OUT, 0.0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_zoom_in_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
if (editor->shell)
|
||||
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_IN, 0.0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_zoom_100_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
if (editor->shell)
|
||||
gimp_display_shell_scale (editor->shell, GIMP_ZOOM_TO, 1.0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_zoom_fit_in_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
if (editor->shell)
|
||||
gimp_display_shell_scale_fit_in (editor->shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_zoom_fit_to_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
if (editor->shell)
|
||||
gimp_display_shell_scale_fit_to (editor->shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_shrink_clicked (GtkWidget *widget,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
if (editor->shell)
|
||||
gimp_display_shell_scale_shrink_wrap (editor->shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor)
|
||||
|
|
@ -706,7 +628,7 @@ gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
|
|||
if (editor->zoom_adjustment)
|
||||
{
|
||||
gdouble val;
|
||||
|
||||
|
||||
val = log (CLAMP (editor->shell->scale, 1.0 / 256, 256.0) ) / G_LN2;
|
||||
|
||||
g_signal_handlers_block_by_func (editor->zoom_adjustment,
|
||||
|
|
@ -721,6 +643,10 @@ gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
|
|||
}
|
||||
|
||||
gimp_navigation_editor_update_marker (editor);
|
||||
|
||||
if (GIMP_EDITOR (editor)->ui_manager)
|
||||
gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager,
|
||||
GIMP_EDITOR (editor)->popup_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -728,6 +654,10 @@ gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
|
|||
GimpNavigationEditor *editor)
|
||||
{
|
||||
gimp_navigation_editor_update_marker (editor);
|
||||
|
||||
if (GIMP_EDITOR (editor)->ui_manager)
|
||||
gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager,
|
||||
GIMP_EDITOR (editor)->popup_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -736,6 +666,10 @@ gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
|
|||
{
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view),
|
||||
GIMP_VIEWABLE (shell->gdisp->gimage));
|
||||
|
||||
if (GIMP_EDITOR (editor)->ui_manager)
|
||||
gimp_ui_manager_update (GIMP_EDITOR (editor)->ui_manager,
|
||||
GIMP_EDITOR (editor)->popup_data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -66,15 +66,11 @@ struct _GimpNavigationEditorClass
|
|||
|
||||
GType gimp_navigation_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_navigation_editor_new (GimpDisplayShell *shell,
|
||||
GimpDisplayConfig *config);
|
||||
void gimp_navigation_editor_set_shell (GimpNavigationEditor *view,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
void gimp_navigation_editor_popup (GimpDisplayShell *shell,
|
||||
GtkWidget *widget,
|
||||
gint click_x,
|
||||
gint click_y);
|
||||
GtkWidget * gimp_navigation_editor_new (GimpMenuFactory *menu_factory);
|
||||
void gimp_navigation_editor_popup (GimpDisplayShell *shell,
|
||||
GtkWidget *widget,
|
||||
gint click_x,
|
||||
gint click_y);
|
||||
|
||||
|
||||
#endif /* __GIMP_NAVIGATION_EDITOR_H__ */
|
||||
|
|
|
|||
|
|
@ -255,6 +255,11 @@ menus_init (Gimp *gimp,
|
|||
"selection-editor-menu.xml", NULL,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<NavigationEditor>",
|
||||
"view",
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<UndoEditor>",
|
||||
"edit",
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -566,7 +566,16 @@ gimp_editor_add_action_button (GimpEditor *editor,
|
|||
|
||||
button_icon_size = gimp_editor_ensure_button_box (editor);
|
||||
|
||||
button = gimp_button_new ();
|
||||
if (GTK_IS_TOGGLE_ACTION (action))
|
||||
{
|
||||
button = gtk_toggle_button_new ();
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
button = gimp_button_new ();
|
||||
}
|
||||
|
||||
gtk_action_connect_proxy (action, button);
|
||||
gtk_box_pack_start (GTK_BOX (editor->button_box), button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
|
|
|||
Loading…
Reference in a new issue