From b0f83a4b4f21f83d884cccee36961b21debace95 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 28 Jan 2005 19:48:31 +0000 Subject: [PATCH] app/actions/Makefile.am new files holding utility functions to create 2005-01-28 Michael Natterer * app/actions/Makefile.am * app/actions/window-actions.[ch]: new files holding utility functions to create actions to move windows to other screens. * app/actions/dock-actions.c * app/actions/dock-commands.[ch] * app/actions/view-actions.c * app/actions/view-commands.[ch]: use the new actions instead of the change screen dialog. * app/menus/Makefile.am * app/menus/window-menu.[ch]: new files which create menu items for above actions. * app/menus/dockable-menu.[ch]: new files using above window-menu utility functions. * app/menus/image-menu.c: use them here too. * app/menus/menus.c: set a setup_func for the "" UI manager. * menus/dockable-menu.xml.in * menus/image-menu.xml.in: changed accordingly. --- ChangeLog | 27 ++++++++ app/actions/Makefile.am | 4 +- app/actions/dock-actions.c | 26 +++++--- app/actions/dock-commands.c | 111 ++++++++---------------------- app/actions/dock-commands.h | 3 +- app/actions/view-actions.c | 34 +++++----- app/actions/view-commands.c | 84 +++++------------------ app/actions/view-commands.h | 7 +- app/actions/window-actions.c | 126 +++++++++++++++++++++++++++++++++++ app/actions/window-actions.h | 30 +++++++++ app/menus/Makefile.am | 6 +- app/menus/dockable-menu.c | 34 ++++++++++ app/menus/dockable-menu.h | 27 ++++++++ app/menus/image-menu.c | 7 ++ app/menus/menus.c | 3 +- app/menus/window-menu.c | 72 ++++++++++++++++++++ app/menus/window-menu.h | 28 ++++++++ menus/dockable-menu.xml.in | 2 +- menus/image-menu.xml.in | 2 +- 19 files changed, 448 insertions(+), 185 deletions(-) create mode 100644 app/actions/window-actions.c create mode 100644 app/actions/window-actions.h create mode 100644 app/menus/dockable-menu.c create mode 100644 app/menus/dockable-menu.h create mode 100644 app/menus/window-menu.c create mode 100644 app/menus/window-menu.h diff --git a/ChangeLog b/ChangeLog index 7f9225b022..10f595aeee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2005-01-28 Michael Natterer + + * app/actions/Makefile.am + * app/actions/window-actions.[ch]: new files holding utility + functions to create actions to move windows to other screens. + + * app/actions/dock-actions.c + * app/actions/dock-commands.[ch] + * app/actions/view-actions.c + * app/actions/view-commands.[ch]: use the new actions instead of + the change screen dialog. + + * app/menus/Makefile.am + * app/menus/window-menu.[ch]: new files which create menu items + for above actions. + + * app/menus/dockable-menu.[ch]: new files using above window-menu + utility functions. + + * app/menus/image-menu.c: use them here too. + + * app/menus/menus.c: set a setup_func for the "" + UI manager. + + * menus/dockable-menu.xml.in + * menus/image-menu.xml.in: changed accordingly. + 2005-01-26 Bill Skaggs * libgimp/gimpdrawablepreview.c: set preview bounds correctly diff --git a/app/actions/Makefile.am b/app/actions/Makefile.am index e5da42d17e..4585ba540b 100644 --- a/app/actions/Makefile.am +++ b/app/actions/Makefile.am @@ -136,7 +136,9 @@ libappactions_a_SOURCES = \ view-actions.c \ view-actions.h \ view-commands.c \ - view-commands.h + view-commands.h \ + window-actions.c \ + window-actions.h EXTRA_DIST = \ diff --git a/app/actions/dock-actions.c b/app/actions/dock-actions.c index 23fba499e2..b4ece43928 100644 --- a/app/actions/dock-actions.c +++ b/app/actions/dock-actions.c @@ -31,21 +31,21 @@ #include "actions.h" #include "dock-actions.h" #include "dock-commands.h" +#include "window-actions.h" #include "gimp-intl.h" static GimpActionEntry dock_actions[] = { + { "dock-move-to-screen-menu", GIMP_STOCK_MOVE_TO_SCREEN, + N_("M_ove to Screen"), NULL, NULL, NULL, + GIMP_HELP_DOCK_CHANGE_SCREEN }, + { "dock-close", GTK_STOCK_CLOSE, N_("Close Dock"), "W", NULL, G_CALLBACK (dock_close_cmd_callback), - GIMP_HELP_DOCK_CLOSE }, - - { "dock-move-to-screen", GIMP_STOCK_MOVE_TO_SCREEN, - N_("M_ove to Screen..."), NULL, NULL, - G_CALLBACK (dock_change_screen_cmd_callback), - GIMP_HELP_DOCK_CHANGE_SCREEN } + GIMP_HELP_DOCK_CLOSE } }; static GimpToggleActionEntry dock_toggle_actions[] = @@ -74,6 +74,10 @@ dock_actions_setup (GimpActionGroup *group) gimp_action_group_add_toggle_actions (group, dock_toggle_actions, G_N_ELEMENTS (dock_toggle_actions)); + + window_actions_setup (group, + GIMP_HELP_DOCK_CHANGE_SCREEN, + G_CALLBACK (dock_move_to_screen_cmd_callback)); } void @@ -81,16 +85,16 @@ dock_actions_update (GimpActionGroup *group, gpointer data) { GtkWidget *widget = action_data_get_widget (data); - GtkWidget *toplevel = gtk_widget_get_toplevel (widget); - gint n_screens = 1; + GtkWidget *toplevel = NULL; + + if (widget) + toplevel = gtk_widget_get_toplevel (widget); #define SET_ACTIVE(action,active) \ gimp_action_group_set_action_active (group, action, (active) != 0) #define SET_VISIBLE(action,active) \ gimp_action_group_set_action_visible (group, action, (active) != 0) - n_screens = gdk_display_get_n_screens (gtk_widget_get_display (toplevel)); - if (GIMP_IS_IMAGE_DOCK (toplevel)) { GimpImageDock *image_dock = GIMP_IMAGE_DOCK (toplevel); @@ -107,7 +111,7 @@ dock_actions_update (GimpActionGroup *group, SET_VISIBLE ("dock-auto-follow-active", FALSE); } - SET_VISIBLE ("dock-move-to-screen", n_screens > 1); + window_actions_update (group, toplevel); #undef SET_ACTIVE #undef SET_VISIBLE diff --git a/app/actions/dock-commands.c b/app/actions/dock-commands.c index 3a90aa5663..2a121cb933 100644 --- a/app/actions/dock-commands.c +++ b/app/actions/dock-commands.c @@ -30,15 +30,6 @@ #include "dock-commands.h" -/* local function prototypes */ - -static void dock_change_screen_confirm_callback (GtkWidget *dialog, - gint value, - gpointer data); -static void dock_change_screen_destroy_callback (GtkWidget *dialog, - GtkWidget *dock); - - /* public functions */ void @@ -46,16 +37,16 @@ dock_close_cmd_callback (GtkAction *action, gpointer data) { GtkWidget *widget; - GtkWidget *toplevel; return_if_no_widget (widget, data); - toplevel = gtk_widget_get_toplevel (widget); + if (! GTK_WIDGET_TOPLEVEL (widget)) + widget = gtk_widget_get_toplevel (widget); - if (toplevel && toplevel->window) + if (widget && widget->window) { GdkEvent *event = gdk_event_new (GDK_DELETE); - event->any.window = g_object_ref (toplevel->window); + event->any.window = g_object_ref (widget->window); event->any.send_event = TRUE; gtk_main_do_event (event); @@ -64,50 +55,30 @@ dock_close_cmd_callback (GtkAction *action, } void -dock_change_screen_cmd_callback (GtkAction *action, - gpointer data) +dock_move_to_screen_cmd_callback (GtkAction *action, + GtkAction *current, + gpointer data) { - GtkWidget *widget; - GtkWidget *toplevel; - GdkScreen *screen; - GdkDisplay *display; - gint cur_screen; - gint num_screens; - GtkWidget *dialog; + GtkWidget *widget; + gint value; return_if_no_widget (widget, data); - toplevel = gtk_widget_get_toplevel (widget); + if (! GTK_WIDGET_TOPLEVEL (widget)) + widget = gtk_widget_get_toplevel (widget); - dialog = g_object_get_data (G_OBJECT (toplevel), "gimp-change-screen-dialog"); + value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); - if (dialog) + if (value != gdk_screen_get_number (gtk_widget_get_screen (widget))) { - gtk_window_present (GTK_WINDOW (dialog)); - return; + GdkDisplay *display; + GdkScreen *screen; + + display = gtk_widget_get_display (widget); + screen = gdk_display_get_screen (display, value); + + if (screen) + gtk_window_set_screen (GTK_WINDOW (widget), screen); } - - screen = gtk_widget_get_screen (toplevel); - display = gtk_widget_get_display (toplevel); - - cur_screen = gdk_screen_get_number (screen); - num_screens = gdk_display_get_n_screens (display); - - dialog = gimp_query_int_box ("Move Dock to Screen", - toplevel, - NULL, NULL, - "Enter destination screen", - cur_screen, 0, num_screens - 1, - G_OBJECT (toplevel), "destroy", - dock_change_screen_confirm_callback, - toplevel); - - g_object_set_data (G_OBJECT (toplevel), "gimp-change-screen-dialog", dialog); - - g_signal_connect (dialog, "destroy", - G_CALLBACK (dock_change_screen_destroy_callback), - toplevel); - - gtk_widget_show (dialog); } void @@ -115,16 +86,16 @@ dock_toggle_image_menu_cmd_callback (GtkAction *action, gpointer data) { GtkWidget *widget; - GtkWidget *toplevel; gboolean active; return_if_no_widget (widget, data); - toplevel = gtk_widget_get_toplevel (widget); + if (! GTK_WIDGET_TOPLEVEL (widget)) + widget = gtk_widget_get_toplevel (widget); active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); - if (GIMP_IS_IMAGE_DOCK (toplevel)) - gimp_image_dock_set_show_image_menu (GIMP_IMAGE_DOCK (toplevel), active); + if (GIMP_IS_IMAGE_DOCK (widget)) + gimp_image_dock_set_show_image_menu (GIMP_IMAGE_DOCK (widget), active); } void @@ -132,38 +103,14 @@ dock_toggle_auto_cmd_callback (GtkAction *action, gpointer data) { GtkWidget *widget; - GtkWidget *toplevel; gboolean active; return_if_no_widget (widget, data); - toplevel = gtk_widget_get_toplevel (widget); + if (! GTK_WIDGET_TOPLEVEL (widget)) + widget = gtk_widget_get_toplevel (widget); active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); - if (GIMP_IS_IMAGE_DOCK (toplevel)) - gimp_image_dock_set_auto_follow_active (GIMP_IMAGE_DOCK (toplevel), active); -} - - -/* private functions */ - -static void -dock_change_screen_confirm_callback (GtkWidget *dialog, - gint value, - gpointer data) -{ - GdkScreen *screen; - - screen = gdk_display_get_screen (gtk_widget_get_display (GTK_WIDGET (data)), - value); - - if (screen) - gtk_window_set_screen (GTK_WINDOW (data), screen); -} - -static void -dock_change_screen_destroy_callback (GtkWidget *dialog, - GtkWidget *dock) -{ - g_object_set_data (G_OBJECT (dock), "gimp-change-screen-dialog", NULL); + if (GIMP_IS_IMAGE_DOCK (widget)) + gimp_image_dock_set_auto_follow_active (GIMP_IMAGE_DOCK (widget), active); } diff --git a/app/actions/dock-commands.h b/app/actions/dock-commands.h index 8a2173d99b..cf7f19b799 100644 --- a/app/actions/dock-commands.h +++ b/app/actions/dock-commands.h @@ -22,7 +22,8 @@ void dock_close_cmd_callback (GtkAction *action, gpointer data); -void dock_change_screen_cmd_callback (GtkAction *action, +void dock_move_to_screen_cmd_callback (GtkAction *action, + GtkAction *current, gpointer data); void dock_toggle_image_menu_cmd_callback (GtkAction *action, diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c index 4a3b5bb3dc..74132369d0 100644 --- a/app/actions/view-actions.c +++ b/app/actions/view-actions.c @@ -45,6 +45,7 @@ #include "actions.h" #include "view-actions.h" #include "view-commands.h" +#include "window-actions.h" #include "gimp-intl.h" @@ -60,9 +61,12 @@ static void view_actions_check_type_notify (GimpDisplayConfig *config, static GimpActionEntry view_actions[] = { - { "view-menu", NULL, N_("_View") }, - { "view-zoom-menu", NULL, N_("_Zoom") }, - { "view-padding-color-menu", NULL, N_("_Padding Color") }, + { "view-menu", NULL, N_("_View") }, + { "view-zoom-menu", NULL, N_("_Zoom") }, + { "view-padding-color-menu", NULL, N_("_Padding Color") }, + { "view-move-to-screen-menu", GIMP_STOCK_MOVE_TO_SCREEN, + N_("Move to Screen"), NULL, NULL, NULL, + GIMP_HELP_VIEW_CHANGE_SCREEN }, { "view-new", GTK_STOCK_NEW, N_("_New View"), "", NULL, @@ -105,12 +109,7 @@ static GimpActionEntry view_actions[] = N_("Shrink _Wrap"), "E", N_("Shrink wrap"), G_CALLBACK (view_shrink_wrap_cmd_callback), - GIMP_HELP_VIEW_SHRINK_WRAP }, - - { "view-move-to-screen", GIMP_STOCK_MOVE_TO_SCREEN, - N_("Move to Screen..."), NULL, NULL, - G_CALLBACK (view_change_screen_cmd_callback), - GIMP_HELP_VIEW_CHANGE_SCREEN } + GIMP_HELP_VIEW_SHRINK_WRAP } }; static GimpToggleActionEntry view_toggle_actions[] = @@ -438,6 +437,10 @@ view_actions_setup (GimpActionGroup *group) G_N_ELEMENTS (view_scroll_vertical_actions), G_CALLBACK (view_scroll_vertical_cmd_callback)); + window_actions_setup (group, + GIMP_HELP_VIEW_CHANGE_SCREEN, + G_CALLBACK (view_move_to_screen_cmd_callback)); + /* connect "activate" of view-zoom-other manually so it can be * selected even if it's the active item of the radio group */ @@ -463,7 +466,6 @@ view_actions_update (GimpActionGroup *group, GimpDisplayOptions *options = NULL; GimpImage *gimage = NULL; gboolean fullscreen = FALSE; - gint n_screens = 1; if (gdisp) { @@ -473,9 +475,6 @@ view_actions_update (GimpActionGroup *group, fullscreen = gimp_display_shell_get_fullscreen (shell); options = fullscreen ? shell->fullscreen_options : shell->options; - - n_screens = - gdk_display_get_n_screens (gtk_widget_get_display (GTK_WIDGET (shell))); } #define SET_ACTIVE(action,condition) \ @@ -555,10 +554,11 @@ view_actions_update (GimpActionGroup *group, SET_SENSITIVE ("view-show-statusbar", gdisp); SET_ACTIVE ("view-show-statusbar", gdisp && options->show_statusbar); - SET_SENSITIVE ("view-shrink-wrap", gdisp); - SET_SENSITIVE ("view-fullscreen", gdisp); - SET_ACTIVE ("view-fullscreen", gdisp && fullscreen); - SET_VISIBLE ("view-move-to-screen", gdisp && n_screens > 1); + SET_SENSITIVE ("view-shrink-wrap", gdisp); + SET_SENSITIVE ("view-fullscreen", gdisp); + SET_ACTIVE ("view-fullscreen", gdisp && fullscreen); + + window_actions_update (group, gdisp ? gdisp->shell : NULL); #undef SET_ACTIVE #undef SET_VISIBLE diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c index ce4a7a8da1..3a35f2b74a 100644 --- a/app/actions/view-commands.c +++ b/app/actions/view-commands.c @@ -67,15 +67,10 @@ /* local function prototypes */ -static void view_padding_color_dialog_update (GimpColorDialog *dialog, - const GimpRGB *color, - GimpColorDialogState state, - GimpDisplayShell *shell); -static void view_change_screen_confirm_callback (GtkWidget *dialog, - gint value, - gpointer data); -static void view_change_screen_destroy_callback (GtkWidget *dialog, - GtkWidget *shell); +static void view_padding_color_dialog_update (GimpColorDialog *dialog, + const GimpRGB *color, + GimpColorDialogState state, + GimpDisplayShell *shell); /* public functions */ @@ -672,49 +667,27 @@ view_fullscreen_cmd_callback (GtkAction *action, } void -view_change_screen_cmd_callback (GtkAction *action, - gpointer data) +view_move_to_screen_cmd_callback (GtkAction *action, + GtkAction *current, + gpointer data) { GimpDisplay *gdisp; - GdkScreen *screen; - GdkDisplay *display; - gint cur_screen; - gint num_screens; - GtkWidget *dialog; + gint value; return_if_no_display (gdisp, data); - dialog = g_object_get_data (G_OBJECT (gdisp->shell), - "gimp-change-screen-dialog"); + value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); - if (dialog) + if (value != gdk_screen_get_number (gtk_widget_get_screen (gdisp->shell))) { - gtk_window_present (GTK_WINDOW (dialog)); - return; + GdkDisplay *display; + GdkScreen *screen; + + display = gtk_widget_get_display (gdisp->shell); + screen = gdk_display_get_screen (display, value); + + if (screen) + gtk_window_set_screen (GTK_WINDOW (gdisp->shell), screen); } - - screen = gtk_widget_get_screen (gdisp->shell); - display = gtk_widget_get_display (gdisp->shell); - - cur_screen = gdk_screen_get_number (screen); - num_screens = gdk_display_get_n_screens (display); - - dialog = gimp_query_int_box ("Move Display to Screen", - gdisp->shell, - NULL, NULL, - "Enter destination screen", - cur_screen, 0, num_screens - 1, - G_OBJECT (gdisp->shell), "destroy", - view_change_screen_confirm_callback, - gdisp->shell); - - g_object_set_data (G_OBJECT (gdisp->shell), "gimp-change-screen-dialog", - dialog); - - g_signal_connect (dialog, "destroy", - G_CALLBACK (view_change_screen_destroy_callback), - gdisp->shell); - - gtk_widget_show (dialog); } @@ -753,24 +726,3 @@ view_padding_color_dialog_update (GimpColorDialog *dialog, break; } } - -static void -view_change_screen_confirm_callback (GtkWidget *dialog, - gint value, - gpointer data) -{ - GdkScreen *screen; - - screen = gdk_display_get_screen (gtk_widget_get_display (GTK_WIDGET (data)), - value); - - if (screen) - gtk_window_set_screen (GTK_WINDOW (data), screen); -} - -static void -view_change_screen_destroy_callback (GtkWidget *dialog, - GtkWidget *shell) -{ - g_object_set_data (G_OBJECT (shell), "gimp-change-screen-dialog", NULL); -} diff --git a/app/actions/view-commands.h b/app/actions/view-commands.h index 8ca7f2b53f..5bdc718c4c 100644 --- a/app/actions/view-commands.h +++ b/app/actions/view-commands.h @@ -85,9 +85,10 @@ void view_padding_color_cmd_callback (GtkAction *action, void view_shrink_wrap_cmd_callback (GtkAction *action, gpointer data); void view_fullscreen_cmd_callback (GtkAction *action, - gpointer data); -void view_change_screen_cmd_callback (GtkAction *action, - gpointer data); + gpointer data); +void view_move_to_screen_cmd_callback (GtkAction *action, + GtkAction *current, + gpointer data); #endif /* __VIEW_COMMANDS_H__ */ diff --git a/app/actions/window-actions.c b/app/actions/window-actions.c new file mode 100644 index 0000000000..feedf2c73b --- /dev/null +++ b/app/actions/window-actions.c @@ -0,0 +1,126 @@ +/* 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 "libgimpwidgets/gimpwidgets.h" + +#include "actions-types.h" + +#include "widgets/gimpactiongroup.h" +#include "widgets/gimphelp-ids.h" + +#include "actions.h" +#include "window-actions.h" + +#include "gimp-intl.h" + + +void +window_actions_setup (GimpActionGroup *group, + const gchar *move_to_screen_help_id, + GCallback move_to_screen_callback) +{ + GdkDisplay *display; + GimpRadioActionEntry *entries; + const gchar *group_name; + gint n_entries; + gint i; + + display = gdk_display_get_default (); + n_entries = gdk_display_get_n_screens (display); + + group_name = gtk_action_group_get_name (GTK_ACTION_GROUP (group)); + + entries = g_new0 (GimpRadioActionEntry, n_entries); + + for (i = 0; i < n_entries; i++) + { + GdkScreen *screen; + gchar *screen_name; + + screen = gdk_display_get_screen (display, i); + screen_name = gdk_screen_make_display_name (screen); + + entries[i].name = g_strdup_printf ("%s-move-to-screen-%02d", + group_name, i); + entries[i].stock_id = GIMP_STOCK_MOVE_TO_SCREEN; + entries[i].label = g_strdup_printf (_("Screen %d (%s)"), + i, screen_name); + entries[i].accelerator = NULL; + entries[i].tooltip = NULL; + entries[i].value = i; + entries[i].help_id = move_to_screen_help_id; + + g_free (screen_name); + } + + gimp_action_group_add_radio_actions (group, entries, n_entries, 0, + G_CALLBACK (move_to_screen_callback)); + + for (i = 0; i < n_entries; i++) + { + g_free ((gchar *) entries[i].name); + g_free ((gchar *) entries[i].label); + } + + g_free (entries); +} + +void +window_actions_update (GimpActionGroup *group, + GtkWidget *window) +{ + const gchar *group_name; + gint n_screens = 1; + gchar *name; + + group_name = gtk_action_group_get_name (GTK_ACTION_GROUP (group)); + +#define SET_ACTIVE(action,active) \ + gimp_action_group_set_action_active (group, action, (active) != 0) +#define SET_VISIBLE(action,active) \ + gimp_action_group_set_action_visible (group, action, (active) != 0) + + if (GTK_IS_WINDOW (window)) + { + GdkDisplay *display; + GdkScreen *screen; + gint cur_screen; + + display = gtk_widget_get_display (window); + screen = gtk_widget_get_screen (window); + + n_screens = gdk_display_get_n_screens (display); + cur_screen = gdk_screen_get_number (screen); + + name = g_strdup_printf ("%s-move-to-screen-%02d", + group_name, cur_screen); + SET_ACTIVE (name, TRUE); + g_free (name); + } + + name = g_strdup_printf ("%s-move-to-screen-menu", group_name); + SET_VISIBLE (name, n_screens > 1); + g_free (name); + +#undef SET_ACTIVE +#undef SET_VISIBLE +} diff --git a/app/actions/window-actions.h b/app/actions/window-actions.h new file mode 100644 index 0000000000..92bc220ba2 --- /dev/null +++ b/app/actions/window-actions.h @@ -0,0 +1,30 @@ +/* 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. + */ + +#ifndef __WINDOW_ACTIONS_H__ +#define __WINDOW_ACTIONS_H__ + + +void window_actions_setup (GimpActionGroup *group, + const gchar *move_to_screen_help_id, + GCallback move_to_screen_callback); +void window_actions_update (GimpActionGroup *group, + GtkWidget *window); + + +#endif /* __WINDOW_ACTIONS_H__ */ diff --git a/app/menus/Makefile.am b/app/menus/Makefile.am index 23cb7ca383..831b82569c 100644 --- a/app/menus/Makefile.am +++ b/app/menus/Makefile.am @@ -6,6 +6,8 @@ libappmenus_a_SOURCES = \ menus-types.h \ menus.c \ menus.h \ + dockable-menu.c \ + dockable-menu.h \ file-menu.c \ file-menu.h \ image-menu.c \ @@ -15,7 +17,9 @@ libappmenus_a_SOURCES = \ tool-options-menu.c \ tool-options-menu.h \ toolbox-menu.c \ - toolbox-menu.h + toolbox-menu.h \ + window-menu.c \ + window-menu.h EXTRA_DIST = \ diff --git a/app/menus/dockable-menu.c b/app/menus/dockable-menu.c new file mode 100644 index 0000000000..4113859a34 --- /dev/null +++ b/app/menus/dockable-menu.c @@ -0,0 +1,34 @@ +/* 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 "menus-types.h" + +#include "dockable-menu.h" +#include "window-menu.h" + + +void +dockable_menu_setup (GimpUIManager *manager, + const gchar *ui_path) +{ + window_menu_setup (manager, "dock", ui_path); +} diff --git a/app/menus/dockable-menu.h b/app/menus/dockable-menu.h new file mode 100644 index 0000000000..49be611256 --- /dev/null +++ b/app/menus/dockable-menu.h @@ -0,0 +1,27 @@ +/* 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. + */ + +#ifndef __DOCKABLE_MENU_H__ +#define __DOCKABLE_MENU_H__ + + +void dockable_menu_setup (GimpUIManager *manager, + const gchar *ui_path); + + +#endif /* __DOCKABLE_MENU_H__ */ diff --git a/app/menus/image-menu.c b/app/menus/image-menu.c index 28bcbcc8f0..11dc0f0e29 100644 --- a/app/menus/image-menu.c +++ b/app/menus/image-menu.c @@ -27,15 +27,22 @@ #include "file-menu.h" #include "image-menu.h" #include "plug-in-menus.h" +#include "window-menu.h" void image_menu_setup (GimpUIManager *manager, const gchar *ui_path) { + gchar *path; + if (! strcmp (ui_path, "/dummy-menubar")) ui_path = "/dummy-menubar/image-popup"; file_menu_setup (manager, ui_path); plug_in_menus_setup (manager, ui_path); + + path = g_strconcat (ui_path, "/View", NULL); + window_menu_setup (manager, "view", path); + g_free (path); } diff --git a/app/menus/menus.c b/app/menus/menus.c index 80c85c133e..bd3bc9d661 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -40,6 +40,7 @@ #include "widgets/gimpactionfactory.h" #include "widgets/gimpmenufactory.h" +#include "dockable-menu.h" #include "image-menu.h" #include "menus.h" #include "tool-options-menu.h" @@ -155,7 +156,7 @@ menus_init (Gimp *gimp, "dock", NULL, "/dockable-popup", - "dockable-menu.xml", NULL, + "dockable-menu.xml", dockable_menu_setup, NULL); gimp_menu_factory_manager_register (global_menu_factory, "", diff --git a/app/menus/window-menu.c b/app/menus/window-menu.c new file mode 100644 index 0000000000..8c99beeb85 --- /dev/null +++ b/app/menus/window-menu.c @@ -0,0 +1,72 @@ +/* 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 "menus-types.h" + +#include "config/gimpguiconfig.h" + +#include "core/gimp.h" + +#include "widgets/gimpuimanager.h" + +#include "window-menu.h" + + +void +window_menu_setup (GimpUIManager *manager, + const gchar *group_name, + const gchar *ui_path) +{ + GdkDisplay *display; + GtkUIManager *ui_manager; + gint n_entries; + guint merge_id; + gint i; + + g_return_if_fail (GIMP_IS_UI_MANAGER (manager)); + g_return_if_fail (ui_path != NULL); + + ui_manager = GTK_UI_MANAGER (manager); + + display = gdk_display_get_default (); + n_entries = gdk_display_get_n_screens (display); + + merge_id = gtk_ui_manager_new_merge_id (ui_manager); + + for (i = 0; i < n_entries; i++) + { + gchar *action_name; + gchar *action_path; + + action_name = g_strdup_printf ("%s-move-to-screen-%02d", + group_name, i); + action_path = g_strdup_printf ("%s/Move to Screen", ui_path); + + gtk_ui_manager_add_ui (ui_manager, merge_id, + action_path, action_name, action_name, + GTK_UI_MANAGER_MENUITEM, + FALSE); + + g_free (action_name); + g_free (action_path); + } +} diff --git a/app/menus/window-menu.h b/app/menus/window-menu.h new file mode 100644 index 0000000000..79f1058f27 --- /dev/null +++ b/app/menus/window-menu.h @@ -0,0 +1,28 @@ +/* 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. + */ + +#ifndef __WINDOW_MENU_H__ +#define __WINDOW_MENU_H__ + + +void window_menu_setup (GimpUIManager *manager, + const gchar *group_name, + const gchar *ui_path); + + +#endif /* __WINDOW_MENU_H__ */ diff --git a/menus/dockable-menu.xml.in b/menus/dockable-menu.xml.in index 3bd4bbd921..5d4ebf1573 100644 --- a/menus/dockable-menu.xml.in +++ b/menus/dockable-menu.xml.in @@ -32,6 +32,6 @@ - + diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index 8d399c6476..2ded6948e3 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -229,7 +229,7 @@ - +