Commit f9a2c5cf authored by Martin Nordholts's avatar Martin Nordholts

app: Add Windows→Hide docks menu item

Add Windows→Hide docks menu item. We don't remove the hardcoding of
having Tab trigger it though, because gtk_accelerator_valid() returns
FALSE for GDK_tab. This means that if the user changes keyboard
shortcut for the menu item, both the user shortcut and the hardcoded
shortcut will work. We remove gimp_dialog_factories_toggle() and make
clients activate the action instead to toggle dock visibility.
parent 6d6a52b5
......@@ -97,6 +97,20 @@ static const GimpActionEntry windows_actions[] =
static const GimpToggleActionEntry windows_toggle_actions[] =
{
{ "windows-hide-docks", NULL,
NC_("windows-action", "Hide docks"),
/* The only reason we have Tab here is to give away the hardcoded
* keyboard shortcut. If the user changes the shortcut to
* something else, both that shortcut and Tab will work. The
* reason we have the shortcut hardcoded is beccause
* gtk_accelerator_valid() returns FALSE for GDK_tab.
*/
"Tab",
NC_("windows-action", "When enabled docks and other dialogs are hidden, leaving only image windows."),
G_CALLBACK (windows_hide_docks_cmd_callback),
FALSE,
GIMP_HELP_WINDOWS_HIDE_DOCKS },
{ "windows-use-single-window-mode", NULL,
NC_("windows-action", "Single-window mode"), NULL,
NC_("windows-action", "When enabled GIMP is in a single-window mode. Far from completely implemented!"),
......@@ -187,6 +201,8 @@ windows_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_ACTIVE ("windows-use-single-window-mode", config->single_window_mode);
SET_ACTIVE ("windows-hide-docks", (gimp_dialog_factories_get_state () !=
GIMP_DIALOGS_SHOWN));
#undef SET_ACTIVE
}
......
......@@ -49,6 +49,24 @@ windows_show_toolbox_cmd_callback (GtkAction *action,
windows_show_toolbox ();
}
void
windows_hide_docks_cmd_callback (GtkAction *action,
gpointer data)
{
gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
GimpDialogsState state = gimp_dialog_factories_get_state ();
GimpDialogsState new_state = state;
/* Make sure the state and toggle action are in sync */
if (active && state == GIMP_DIALOGS_SHOWN)
new_state = GIMP_DIALOGS_HIDDEN_EXPLICITLY;
else if (! active)
new_state = GIMP_DIALOGS_SHOWN;
if (state != new_state)
gimp_dialog_factories_set_state (new_state);
}
void
windows_use_single_window_mode_cmd_callback (GtkAction *action,
gpointer data)
......
......@@ -21,6 +21,8 @@
void windows_show_toolbox_cmd_callback (GtkAction *action,
gpointer data);
void windows_hide_docks_cmd_callback (GtkAction *action,
gpointer data);
void windows_use_single_window_mode_cmd_callback (GtkAction *action,
gpointer data);
void windows_show_display_cmd_callback (GtkAction *action,
......
......@@ -85,6 +85,7 @@
/* local function prototypes */
static void gimp_display_shell_toggle_hide_docks (GimpDisplayShell *shell);
static void gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment,
GimpDisplayShell *shell);
static void gimp_display_shell_hscrollbar_update (GtkAdjustment *adjustment,
......@@ -580,7 +581,7 @@ gimp_display_shell_canvas_no_image_events (GtkWidget *canvas,
if (kevent->keyval == GDK_Tab ||
kevent->keyval == GDK_ISO_Left_Tab)
{
gimp_dialog_factories_toggle ();
gimp_display_shell_toggle_hide_docks (shell);
return TRUE;
}
}
......@@ -1552,7 +1553,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
}
else
{
gimp_dialog_factories_toggle ();
gimp_display_shell_toggle_hide_docks (shell);
}
return_val = TRUE;
......@@ -2010,6 +2011,17 @@ gimp_display_shell_process_tool_event_queue (GimpDisplayShell *shell,
}
}
static void
gimp_display_shell_toggle_hide_docks (GimpDisplayShell *shell)
{
GimpImageWindow *window = gimp_display_shell_get_window (shell);
if (window)
gimp_ui_manager_activate_action (gimp_image_window_get_ui_manager (window),
"windows",
"windows-hide-docks");
}
static void
gimp_display_shell_vscrollbar_update (GtkAdjustment *adjustment,
GimpDisplayShell *shell)
......
......@@ -1136,19 +1136,6 @@ gimp_dialog_factories_hide_with_display (void)
}
}
void
gimp_dialog_factories_toggle (void)
{
if (dialogs_state == GIMP_DIALOGS_SHOWN)
{
gimp_dialog_factories_set_state (GIMP_DIALOGS_HIDDEN_EXPLICITLY);
}
else
{
gimp_dialog_factories_set_state (GIMP_DIALOGS_SHOWN);
}
}
void
gimp_dialog_factories_set_busy (void)
{
......
......@@ -165,7 +165,6 @@ void gimp_dialog_factories_set_state (GimpDialogsState
GimpDialogsState gimp_dialog_factories_get_state (void);
void gimp_dialog_factories_show_with_display (void);
void gimp_dialog_factories_hide_with_display (void);
void gimp_dialog_factories_toggle (void);
void gimp_dialog_factories_set_busy (void);
void gimp_dialog_factories_unset_busy (void);
GimpDialogFactory * gimp_dialog_factory_from_widget (GtkWidget *dialog,
......
......@@ -497,6 +497,7 @@
#define GIMP_HELP_UNIT_DIALOG "gimp-unit-dialog"
#define GIMP_HELP_WINDOWS_SHOW_DOCK "gimp-windows-show-dock"
#define GIMP_HELP_WINDOWS_HIDE_DOCKS "gimp-windows-hide-docks"
#define GIMP_HELP_WINDOWS_USE_SINGLE_WINDOW_MODE "gimp-windows-use-single-window-mode"
#define GIMP_HELP_WINDOWS_OPEN_RECENT_DOCK "gimp-windows-open-recent-dock"
......
......@@ -643,6 +643,7 @@
<menuitem action="windows-show-toolbox" />
</placeholder>
<separator />
<menuitem action="windows-hide-docks" />
<menuitem action="windows-use-single-window-mode" />
<separator />
</menu>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment