2008-05-11 00:21:37 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-05-11 00:21:37 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-05-11 00:21:37 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-05-11 00:21:37 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2008-05-11 00:21:37 +08:00
|
|
|
#include <gtk/gtk.h>
|
2011-05-08 06:00:55 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2008-05-11 00:21:37 +08:00
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "actions-types.h"
|
|
|
|
|
2009-09-27 00:17:27 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimplist.h"
|
|
|
|
|
|
|
|
#include "widgets/gimpactiongroup.h"
|
2008-05-11 16:15:00 +08:00
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
#include "widgets/gimpdock.h"
|
2009-09-15 13:58:14 +08:00
|
|
|
#include "widgets/gimpdockwindow.h"
|
2008-05-11 00:21:37 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2008-05-11 16:15:00 +08:00
|
|
|
#include "dialogs/dialogs.h"
|
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
#include "windows-actions.h"
|
|
|
|
#include "windows-commands.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2009-09-27 00:17:27 +08:00
|
|
|
static void windows_actions_display_add (GimpContainer *container,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpActionGroup *group);
|
|
|
|
static void windows_actions_display_remove (GimpContainer *container,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpActionGroup *group);
|
2013-05-27 23:52:13 +08:00
|
|
|
static void windows_actions_display_reorder (GimpContainer *container,
|
|
|
|
GimpDisplay *display,
|
|
|
|
gint position,
|
|
|
|
GimpActionGroup *group);
|
2009-09-27 00:17:27 +08:00
|
|
|
static void windows_actions_image_notify (GimpDisplay *display,
|
|
|
|
const GParamSpec *unused,
|
|
|
|
GimpActionGroup *group);
|
2011-05-08 06:00:55 +08:00
|
|
|
static void windows_actions_update_display_accels (GimpActionGroup *group);
|
|
|
|
|
2009-09-27 00:17:27 +08:00
|
|
|
static void windows_actions_dock_window_added (GimpDialogFactory *factory,
|
|
|
|
GimpDockWindow *dock_window,
|
|
|
|
GimpActionGroup *group);
|
|
|
|
static void windows_actions_dock_window_removed (GimpDialogFactory *factory,
|
|
|
|
GimpDockWindow *dock_window,
|
|
|
|
GimpActionGroup *group);
|
|
|
|
static void windows_actions_dock_window_notify (GimpDockWindow *dock,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpActionGroup *group);
|
|
|
|
static void windows_actions_recent_add (GimpContainer *container,
|
|
|
|
GimpSessionInfo *info,
|
|
|
|
GimpActionGroup *group);
|
|
|
|
static void windows_actions_recent_remove (GimpContainer *container,
|
|
|
|
GimpSessionInfo *info,
|
|
|
|
GimpActionGroup *group);
|
|
|
|
static void windows_actions_single_window_mode_notify (GimpDisplayConfig *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpActionGroup *group);
|
2008-05-17 00:06:42 +08:00
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
|
2011-05-31 05:46:50 +08:00
|
|
|
/* The only reason we have "Tab" in the action entries below is to
|
|
|
|
* give away the hardcoded keyboard shortcut. If the user changes the
|
|
|
|
* shortcut to something else, both that shortcut and Tab will
|
2013-01-27 23:52:38 +08:00
|
|
|
* work. The reason we have the shortcut hardcoded is because
|
2011-05-31 05:46:50 +08:00
|
|
|
* gtk_accelerator_valid() returns FALSE for GDK_tab.
|
|
|
|
*/
|
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
static const GimpActionEntry windows_actions[] =
|
|
|
|
{
|
2008-12-03 23:27:42 +08:00
|
|
|
{ "windows-menu", NULL, NC_("windows-action",
|
|
|
|
"_Windows") },
|
|
|
|
{ "windows-docks-menu", NULL, NC_("windows-action",
|
|
|
|
"_Recently Closed Docks") },
|
|
|
|
{ "windows-dialogs-menu", NULL, NC_("windows-action",
|
|
|
|
"_Dockable Dialogs") },
|
2011-05-31 05:46:50 +08:00
|
|
|
|
|
|
|
{ "windows-show-display-next", NULL,
|
|
|
|
NC_("windows-action", "Next Image"), "<alt>Tab",
|
|
|
|
NC_("windows-action", "Switch to the next image"),
|
|
|
|
G_CALLBACK (windows_show_display_next_cmd_callback),
|
|
|
|
NULL },
|
|
|
|
|
|
|
|
{ "windows-show-display-previous", NULL,
|
|
|
|
NC_("windows-action", "Previous Image"), "<alt><shift>Tab",
|
|
|
|
NC_("windows-action", "Switch to the previous image"),
|
|
|
|
G_CALLBACK (windows_show_display_previous_cmd_callback),
|
2013-09-15 18:56:17 +08:00
|
|
|
NULL },
|
|
|
|
|
|
|
|
{ "windows-tab-position", NULL, NC_("windows-action",
|
|
|
|
"_Tabs Position") },
|
2008-05-11 00:21:37 +08:00
|
|
|
};
|
|
|
|
|
2009-09-27 00:17:27 +08:00
|
|
|
static const GimpToggleActionEntry windows_toggle_actions[] =
|
|
|
|
{
|
2010-02-21 05:52:21 +08:00
|
|
|
{ "windows-hide-docks", NULL,
|
2011-05-31 05:46:50 +08:00
|
|
|
NC_("windows-action", "Hide Docks"), "Tab",
|
2013-10-11 10:32:04 +08:00
|
|
|
NC_("windows-action", "When enabled, docks and other dialogs are hidden, leaving only image windows."),
|
2010-02-21 05:52:21 +08:00
|
|
|
G_CALLBACK (windows_hide_docks_cmd_callback),
|
|
|
|
FALSE,
|
|
|
|
GIMP_HELP_WINDOWS_HIDE_DOCKS },
|
|
|
|
|
2009-09-27 00:17:27 +08:00
|
|
|
{ "windows-use-single-window-mode", NULL,
|
2010-03-21 01:05:12 +08:00
|
|
|
NC_("windows-action", "Single-Window Mode"), NULL,
|
2013-10-11 10:32:04 +08:00
|
|
|
NC_("windows-action", "When enabled, GIMP is in a single-window mode."),
|
2009-09-27 00:17:27 +08:00
|
|
|
G_CALLBACK (windows_use_single_window_mode_cmd_callback),
|
|
|
|
FALSE,
|
|
|
|
GIMP_HELP_WINDOWS_USE_SINGLE_WINDOW_MODE }
|
|
|
|
};
|
|
|
|
|
2013-09-15 18:56:17 +08:00
|
|
|
static const GimpRadioActionEntry windows_tabs_position_actions[] =
|
|
|
|
{
|
2014-05-12 04:49:22 +08:00
|
|
|
{ "windows-tabs-position-top", "to-top",
|
2013-09-15 18:56:17 +08:00
|
|
|
NC_("windows-tabs-position-action", "_Top"), NULL,
|
2013-10-12 05:54:29 +08:00
|
|
|
NC_("windows-tabs-position-action", "Position the tabs on the top"),
|
2013-10-11 23:30:30 +08:00
|
|
|
GIMP_POSITION_TOP, GIMP_HELP_WINDOWS_TABS_POSITION },
|
2013-09-15 18:56:17 +08:00
|
|
|
|
2014-05-12 04:49:22 +08:00
|
|
|
{ "windows-tabs-position-bottom", "go-bottom",
|
2013-09-15 18:56:17 +08:00
|
|
|
NC_("windows-tabs-position-action", "_Bottom"), NULL,
|
2013-10-12 05:54:29 +08:00
|
|
|
NC_("windows-tabs-position-action", "Position the tabs on the bottom"),
|
2013-10-11 23:30:30 +08:00
|
|
|
GIMP_POSITION_BOTTOM, GIMP_HELP_WINDOWS_TABS_POSITION },
|
2013-09-15 18:56:17 +08:00
|
|
|
|
2014-05-12 04:49:22 +08:00
|
|
|
{ "windows-tabs-position-left", "go-first",
|
2013-09-15 18:56:17 +08:00
|
|
|
NC_("windows-tabs-position-action", "_Left"), NULL,
|
2013-10-12 05:54:29 +08:00
|
|
|
NC_("windows-tabs-position-action", "Position the tabs on the left"),
|
2013-10-11 23:30:30 +08:00
|
|
|
GIMP_POSITION_LEFT, GIMP_HELP_WINDOWS_TABS_POSITION },
|
2013-09-15 18:56:17 +08:00
|
|
|
|
2014-05-12 04:49:22 +08:00
|
|
|
{ "windows-tabs-position-right", "go-last",
|
2013-09-15 18:56:17 +08:00
|
|
|
NC_("windows-tabs-position-action", "_Right"), NULL,
|
2013-10-12 05:54:29 +08:00
|
|
|
NC_("windows-tabs-position-action", "Position the tabs on the right"),
|
2013-10-11 23:30:30 +08:00
|
|
|
GIMP_POSITION_RIGHT, GIMP_HELP_WINDOWS_TABS_POSITION },
|
2013-09-15 18:56:17 +08:00
|
|
|
};
|
2008-05-11 00:21:37 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
windows_actions_setup (GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
2008-12-03 23:27:42 +08:00
|
|
|
gimp_action_group_add_actions (group, "windows-action",
|
2008-05-11 00:21:37 +08:00
|
|
|
windows_actions,
|
|
|
|
G_N_ELEMENTS (windows_actions));
|
|
|
|
|
2009-09-27 00:17:27 +08:00
|
|
|
gimp_action_group_add_toggle_actions (group, "windows-action",
|
|
|
|
windows_toggle_actions,
|
|
|
|
G_N_ELEMENTS (windows_toggle_actions));
|
|
|
|
|
2013-09-15 18:56:17 +08:00
|
|
|
gimp_action_group_add_radio_actions (group, "windows-tabs-position-action",
|
|
|
|
windows_tabs_position_actions,
|
|
|
|
G_N_ELEMENTS (windows_tabs_position_actions),
|
|
|
|
NULL, 0,
|
|
|
|
G_CALLBACK (windows_set_tabs_position_cmd_callback));
|
|
|
|
|
2008-05-17 00:06:42 +08:00
|
|
|
gimp_action_group_set_action_hide_empty (group, "windows-docks-menu", FALSE);
|
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
g_signal_connect_object (group->gimp->displays, "add",
|
|
|
|
G_CALLBACK (windows_actions_display_add),
|
|
|
|
group, 0);
|
|
|
|
g_signal_connect_object (group->gimp->displays, "remove",
|
|
|
|
G_CALLBACK (windows_actions_display_remove),
|
|
|
|
group, 0);
|
2013-05-27 23:52:13 +08:00
|
|
|
g_signal_connect_object (group->gimp->displays, "reorder",
|
|
|
|
G_CALLBACK (windows_actions_display_reorder),
|
|
|
|
group, 0);
|
2008-05-11 00:21:37 +08:00
|
|
|
|
2008-11-03 05:34:14 +08:00
|
|
|
for (list = gimp_get_display_iter (group->gimp);
|
2008-05-11 00:21:37 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpDisplay *display = list->data;
|
|
|
|
|
|
|
|
windows_actions_display_add (group->gimp->displays, display, group);
|
|
|
|
}
|
2008-05-11 16:15:00 +08:00
|
|
|
|
2010-03-01 06:20:57 +08:00
|
|
|
g_signal_connect_object (gimp_dialog_factory_get_singleton (), "dock-window-added",
|
2009-09-26 19:11:42 +08:00
|
|
|
G_CALLBACK (windows_actions_dock_window_added),
|
2008-05-11 16:15:00 +08:00
|
|
|
group, 0);
|
2010-03-01 06:20:57 +08:00
|
|
|
g_signal_connect_object (gimp_dialog_factory_get_singleton (), "dock-window-removed",
|
2009-09-26 19:11:42 +08:00
|
|
|
G_CALLBACK (windows_actions_dock_window_removed),
|
2008-05-11 16:15:00 +08:00
|
|
|
group, 0);
|
|
|
|
|
2010-03-01 06:20:57 +08:00
|
|
|
for (list = gimp_dialog_factory_get_open_dialogs (gimp_dialog_factory_get_singleton ());
|
2008-05-11 16:15:00 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2009-09-26 19:11:42 +08:00
|
|
|
GimpDockWindow *dock_window = list->data;
|
2008-05-11 16:15:00 +08:00
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
if (GIMP_IS_DOCK_WINDOW (dock_window))
|
2010-03-01 06:20:57 +08:00
|
|
|
windows_actions_dock_window_added (gimp_dialog_factory_get_singleton (),
|
2009-12-20 21:41:02 +08:00
|
|
|
dock_window,
|
|
|
|
group);
|
2008-05-11 16:15:00 +08:00
|
|
|
}
|
2008-05-17 00:06:42 +08:00
|
|
|
|
|
|
|
g_signal_connect_object (global_recent_docks, "add",
|
|
|
|
G_CALLBACK (windows_actions_recent_add),
|
|
|
|
group, 0);
|
|
|
|
g_signal_connect_object (global_recent_docks, "remove",
|
|
|
|
G_CALLBACK (windows_actions_recent_remove),
|
|
|
|
group, 0);
|
|
|
|
|
2016-05-01 21:22:44 +08:00
|
|
|
for (list = GIMP_LIST (global_recent_docks)->queue->head;
|
2008-05-17 00:06:42 +08:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpSessionInfo *info = list->data;
|
|
|
|
|
|
|
|
windows_actions_recent_add (global_recent_docks, info, group);
|
|
|
|
}
|
2009-09-27 00:17:27 +08:00
|
|
|
|
|
|
|
g_signal_connect_object (group->gimp->config, "notify::single-window-mode",
|
|
|
|
G_CALLBACK (windows_actions_single_window_mode_notify),
|
|
|
|
group, 0);
|
2008-05-11 00:21:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
windows_actions_update (GimpActionGroup *group,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2009-09-27 00:17:27 +08:00
|
|
|
GimpGuiConfig *config = GIMP_GUI_CONFIG (group->gimp->config);
|
2013-09-15 18:56:17 +08:00
|
|
|
const gchar *action = NULL;
|
2009-09-27 00:17:27 +08:00
|
|
|
|
|
|
|
#define SET_ACTIVE(action,condition) \
|
|
|
|
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
|
|
|
|
|
|
|
SET_ACTIVE ("windows-use-single-window-mode", config->single_window_mode);
|
2010-02-24 03:21:08 +08:00
|
|
|
SET_ACTIVE ("windows-hide-docks", config->hide_docks);
|
2009-09-27 00:17:27 +08:00
|
|
|
|
2013-09-15 18:56:17 +08:00
|
|
|
switch (config->tabs_position)
|
|
|
|
{
|
|
|
|
case GIMP_POSITION_TOP:
|
|
|
|
action = "windows-tabs-position-top";
|
|
|
|
break;
|
|
|
|
case GIMP_POSITION_BOTTOM:
|
|
|
|
action = "windows-tabs-position-bottom";
|
|
|
|
break;
|
|
|
|
case GIMP_POSITION_LEFT:
|
|
|
|
action = "windows-tabs-position-left";
|
|
|
|
break;
|
|
|
|
case GIMP_POSITION_RIGHT:
|
|
|
|
action = "windows-tabs-position-right";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
action = "windows-tabs-position-top";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_action_group_set_action_active (group, action, TRUE);
|
2013-10-25 09:50:04 +08:00
|
|
|
gimp_action_group_set_action_sensitive (group, "windows-tab-position", config->single_window_mode);
|
2013-09-15 18:56:17 +08:00
|
|
|
|
2009-09-27 00:17:27 +08:00
|
|
|
#undef SET_ACTIVE
|
2008-05-11 00:21:37 +08:00
|
|
|
}
|
|
|
|
|
2009-09-15 05:36:03 +08:00
|
|
|
gchar *
|
2009-09-26 19:11:42 +08:00
|
|
|
windows_actions_dock_window_to_action_name (GimpDockWindow *dock_window)
|
2009-09-15 05:36:03 +08:00
|
|
|
{
|
|
|
|
return g_strdup_printf ("windows-dock-%04d",
|
2009-09-15 13:58:14 +08:00
|
|
|
gimp_dock_window_get_id (dock_window));
|
2009-09-15 05:36:03 +08:00
|
|
|
}
|
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
windows_actions_display_add (GimpContainer *container,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
g_signal_connect_object (display, "notify::image",
|
|
|
|
G_CALLBACK (windows_actions_image_notify),
|
|
|
|
group, 0);
|
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
if (gimp_display_get_image (display))
|
2008-05-11 00:21:37 +08:00
|
|
|
windows_actions_image_notify (display, NULL, group);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
windows_actions_display_remove (GimpContainer *container,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
2011-03-15 15:18:48 +08:00
|
|
|
gchar *action_name = gimp_display_get_action_name (display);
|
2008-05-11 00:21:37 +08:00
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (action)
|
|
|
|
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
|
|
|
|
|
|
|
|
g_free (action_name);
|
2011-05-08 06:00:55 +08:00
|
|
|
|
|
|
|
windows_actions_update_display_accels (group);
|
2008-05-11 00:21:37 +08:00
|
|
|
}
|
|
|
|
|
2013-05-27 23:52:13 +08:00
|
|
|
static void
|
|
|
|
windows_actions_display_reorder (GimpContainer *container,
|
|
|
|
GimpDisplay *display,
|
|
|
|
gint new_index,
|
|
|
|
GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
windows_actions_update_display_accels (group);
|
|
|
|
}
|
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
static void
|
|
|
|
windows_actions_image_notify (GimpDisplay *display,
|
|
|
|
const GParamSpec *unused,
|
|
|
|
GimpActionGroup *group)
|
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
|
|
|
|
if (image)
|
2008-05-11 00:21:37 +08:00
|
|
|
{
|
|
|
|
GtkAction *action;
|
2011-03-15 15:18:48 +08:00
|
|
|
gchar *action_name = gimp_display_get_action_name (display);
|
2008-05-11 00:21:37 +08:00
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
action_name);
|
|
|
|
|
|
|
|
if (! action)
|
|
|
|
{
|
|
|
|
GimpActionEntry entry;
|
|
|
|
|
|
|
|
entry.name = action_name;
|
2014-05-07 05:47:38 +08:00
|
|
|
entry.icon_name = GIMP_STOCK_IMAGE;
|
2008-05-11 00:21:37 +08:00
|
|
|
entry.label = "";
|
|
|
|
entry.accelerator = NULL;
|
|
|
|
entry.tooltip = NULL;
|
|
|
|
entry.callback = G_CALLBACK (windows_show_display_cmd_callback);
|
2008-09-22 02:53:14 +08:00
|
|
|
entry.help_id = NULL;
|
2008-05-11 00:21:37 +08:00
|
|
|
|
2008-12-03 23:27:42 +08:00
|
|
|
gimp_action_group_add_actions (group, NULL, &entry, 1);
|
2008-05-11 00:21:37 +08:00
|
|
|
|
2011-04-02 21:38:55 +08:00
|
|
|
gimp_action_group_set_action_always_show_image (group, action_name,
|
|
|
|
TRUE);
|
|
|
|
|
2008-05-11 00:21:37 +08:00
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
action_name);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (action), "display", display);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2012-07-18 04:52:49 +08:00
|
|
|
const gchar *display_name;
|
2008-05-11 00:21:37 +08:00
|
|
|
gchar *escaped;
|
|
|
|
gchar *title;
|
|
|
|
|
2012-07-18 04:52:49 +08:00
|
|
|
display_name = gimp_image_get_display_name (image);
|
|
|
|
escaped = gimp_escape_uline (display_name);
|
2008-05-11 00:21:37 +08:00
|
|
|
|
|
|
|
title = g_strdup_printf ("%s-%d.%d", escaped,
|
2009-10-07 01:20:44 +08:00
|
|
|
gimp_image_get_ID (image),
|
2009-10-06 15:16:46 +08:00
|
|
|
gimp_display_get_instance (display));
|
2008-05-11 00:21:37 +08:00
|
|
|
g_free (escaped);
|
|
|
|
|
|
|
|
g_object_set (action,
|
|
|
|
"label", title,
|
2012-07-18 04:52:49 +08:00
|
|
|
"tooltip", gimp_image_get_display_path (image),
|
2009-10-07 01:20:44 +08:00
|
|
|
"viewable", image,
|
2008-05-11 00:21:37 +08:00
|
|
|
"context", gimp_get_user_context (group->gimp),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_free (title);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (action_name);
|
2011-05-08 06:00:55 +08:00
|
|
|
|
|
|
|
windows_actions_update_display_accels (group);
|
2008-05-11 00:21:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
windows_actions_display_remove (group->gimp->displays, display, group);
|
|
|
|
}
|
|
|
|
}
|
2008-05-11 16:15:00 +08:00
|
|
|
|
2011-05-08 06:00:55 +08:00
|
|
|
static void
|
|
|
|
windows_actions_update_display_accels (GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (list = gimp_get_display_iter (group->gimp), i = 0;
|
|
|
|
list && i < 10;
|
|
|
|
list = g_list_next (list), i++)
|
|
|
|
{
|
|
|
|
GimpDisplay *display = list->data;
|
|
|
|
GtkAction *action;
|
|
|
|
gchar *action_name;
|
|
|
|
|
|
|
|
if (! gimp_display_get_image (display))
|
|
|
|
break;
|
|
|
|
|
|
|
|
action_name = gimp_display_get_action_name (display);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
action_name);
|
2012-02-07 21:06:12 +08:00
|
|
|
g_free (action_name);
|
2011-05-08 06:00:55 +08:00
|
|
|
|
|
|
|
if (action)
|
|
|
|
{
|
|
|
|
const gchar *accel_path;
|
|
|
|
guint accel_key;
|
|
|
|
|
|
|
|
accel_path = gtk_action_get_accel_path (action);
|
|
|
|
|
|
|
|
if (i < 9)
|
|
|
|
accel_key = GDK_KEY_1 + i;
|
|
|
|
else
|
|
|
|
accel_key = GDK_KEY_0;
|
|
|
|
|
|
|
|
gtk_accel_map_change_entry (accel_path,
|
|
|
|
accel_key, GDK_MOD1_MASK,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 16:15:00 +08:00
|
|
|
static void
|
2009-09-26 19:11:42 +08:00
|
|
|
windows_actions_dock_window_added (GimpDialogFactory *factory,
|
|
|
|
GimpDockWindow *dock_window,
|
|
|
|
GimpActionGroup *group)
|
2008-05-11 16:15:00 +08:00
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
GimpActionEntry entry;
|
2009-09-26 19:11:42 +08:00
|
|
|
gchar *action_name = windows_actions_dock_window_to_action_name (dock_window);
|
2008-05-11 16:15:00 +08:00
|
|
|
|
|
|
|
entry.name = action_name;
|
2014-05-07 05:47:38 +08:00
|
|
|
entry.icon_name = NULL;
|
2008-05-11 16:15:00 +08:00
|
|
|
entry.label = "";
|
|
|
|
entry.accelerator = NULL;
|
|
|
|
entry.tooltip = NULL;
|
|
|
|
entry.callback = G_CALLBACK (windows_show_dock_cmd_callback);
|
2008-05-17 22:08:19 +08:00
|
|
|
entry.help_id = GIMP_HELP_WINDOWS_SHOW_DOCK;
|
2008-05-11 16:15:00 +08:00
|
|
|
|
2008-12-03 23:27:42 +08:00
|
|
|
gimp_action_group_add_actions (group, NULL, &entry, 1);
|
2008-05-11 16:15:00 +08:00
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
action_name);
|
|
|
|
|
2008-05-11 17:26:17 +08:00
|
|
|
g_object_set (action,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
NULL);
|
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
g_object_set_data (G_OBJECT (action), "dock-window", dock_window);
|
2008-05-11 16:15:00 +08:00
|
|
|
|
|
|
|
g_free (action_name);
|
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
g_signal_connect_object (dock_window, "notify::title",
|
|
|
|
G_CALLBACK (windows_actions_dock_window_notify),
|
2008-05-11 16:15:00 +08:00
|
|
|
group, 0);
|
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
if (gtk_window_get_title (GTK_WINDOW (dock_window)))
|
|
|
|
windows_actions_dock_window_notify (dock_window, NULL, group);
|
2008-05-11 16:15:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-26 19:11:42 +08:00
|
|
|
windows_actions_dock_window_removed (GimpDialogFactory *factory,
|
|
|
|
GimpDockWindow *dock_window,
|
|
|
|
GimpActionGroup *group)
|
2008-05-11 16:15:00 +08:00
|
|
|
{
|
|
|
|
GtkAction *action;
|
2009-09-26 19:11:42 +08:00
|
|
|
gchar *action_name = windows_actions_dock_window_to_action_name (dock_window);
|
2008-05-11 16:15:00 +08:00
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (action)
|
|
|
|
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
|
|
|
|
|
|
|
|
g_free (action_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-09-26 19:11:42 +08:00
|
|
|
windows_actions_dock_window_notify (GimpDockWindow *dock_window,
|
|
|
|
const GParamSpec *pspec,
|
|
|
|
GimpActionGroup *group)
|
2008-05-11 16:15:00 +08:00
|
|
|
{
|
|
|
|
GtkAction *action;
|
2008-07-22 03:05:35 +08:00
|
|
|
gchar *action_name;
|
2008-05-11 16:15:00 +08:00
|
|
|
|
2009-09-26 19:11:42 +08:00
|
|
|
action_name = windows_actions_dock_window_to_action_name (dock_window);
|
2008-05-11 16:15:00 +08:00
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
2008-07-22 03:05:35 +08:00
|
|
|
g_free (action_name);
|
2008-05-11 16:15:00 +08:00
|
|
|
|
|
|
|
if (action)
|
|
|
|
g_object_set (action,
|
2009-09-26 19:11:42 +08:00
|
|
|
"label", gtk_window_get_title (GTK_WINDOW (dock_window)),
|
|
|
|
"tooltip", gtk_window_get_title (GTK_WINDOW (dock_window)),
|
2008-05-11 16:15:00 +08:00
|
|
|
NULL);
|
|
|
|
}
|
2008-05-17 00:06:42 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
windows_actions_recent_add (GimpContainer *container,
|
|
|
|
GimpSessionInfo *info,
|
|
|
|
GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
GimpActionEntry entry;
|
|
|
|
gint info_id;
|
|
|
|
static gint info_id_counter = 1;
|
|
|
|
gchar *action_name;
|
|
|
|
|
|
|
|
info_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (info),
|
|
|
|
"recent-action-id"));
|
|
|
|
|
|
|
|
if (! info_id)
|
|
|
|
{
|
|
|
|
info_id = info_id_counter++;
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (info), "recent-action-id",
|
|
|
|
GINT_TO_POINTER (info_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
action_name = g_strdup_printf ("windows-recent-%04d", info_id);
|
|
|
|
|
|
|
|
entry.name = action_name;
|
2014-05-07 05:47:38 +08:00
|
|
|
entry.icon_name = NULL;
|
2009-09-01 04:47:18 +08:00
|
|
|
entry.label = gimp_object_get_name (info);
|
2008-05-17 00:06:42 +08:00
|
|
|
entry.accelerator = NULL;
|
2009-09-01 04:47:18 +08:00
|
|
|
entry.tooltip = gimp_object_get_name (info);
|
2008-05-17 00:06:42 +08:00
|
|
|
entry.callback = G_CALLBACK (windows_open_recent_cmd_callback);
|
2008-05-17 22:08:19 +08:00
|
|
|
entry.help_id = GIMP_HELP_WINDOWS_OPEN_RECENT_DOCK;
|
2008-05-17 00:06:42 +08:00
|
|
|
|
2008-12-03 23:27:42 +08:00
|
|
|
gimp_action_group_add_actions (group, NULL, &entry, 1);
|
2008-05-17 00:06:42 +08:00
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
action_name);
|
|
|
|
|
|
|
|
g_object_set (action,
|
|
|
|
"ellipsize", PANGO_ELLIPSIZE_END,
|
|
|
|
"max-width-chars", 30,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (action), "info", info);
|
|
|
|
|
|
|
|
g_free (action_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
windows_actions_recent_remove (GimpContainer *container,
|
|
|
|
GimpSessionInfo *info,
|
|
|
|
GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
GtkAction *action;
|
|
|
|
gint info_id;
|
|
|
|
gchar *action_name;
|
|
|
|
|
|
|
|
info_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (info),
|
|
|
|
"recent-action-id"));
|
|
|
|
|
|
|
|
action_name = g_strdup_printf ("windows-recent-%04d", info_id);
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group), action_name);
|
|
|
|
|
|
|
|
if (action)
|
|
|
|
gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);
|
|
|
|
|
|
|
|
g_free (action_name);
|
|
|
|
}
|
2009-09-27 00:17:27 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
windows_actions_single_window_mode_notify (GimpDisplayConfig *config,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpActionGroup *group)
|
|
|
|
{
|
|
|
|
gimp_action_group_set_action_active (group,
|
|
|
|
"windows-use-single-window-mode",
|
|
|
|
GIMP_GUI_CONFIG (config)->single_window_mode);
|
|
|
|
}
|