PIKApp/app/actions/dialogs-actions.c

457 lines
15 KiB
C

/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikawidgets/pikawidgets.h"
#include "actions-types.h"
#include "core/pika.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikadialogfactory.h"
#include "widgets/pikahelp-ids.h"
#include "widgets/pikasessioninfo.h"
#include "widgets/pikatoolbox.h"
#include "display/pikaimagewindow.h"
#include "actions.h"
#include "dialogs-actions.h"
#include "dialogs-commands.h"
#include "pika-intl.h"
const PikaStringActionEntry dialogs_dockable_actions[] =
{
{ "dialogs-toolbox", NULL,
NC_("windows-action", "Tool_box"), NULL, { "<primary>B", NULL },
NULL /* set in dialogs_actions_update() */,
"pika-toolbox",
PIKA_HELP_TOOLBOX },
{ "dialogs-tool-options", PIKA_ICON_DIALOG_TOOL_OPTIONS,
NC_("dialogs-action", "Tool _Options Dialog"),
NC_("dialogs-action", "Tool _Options"),
{ NULL },
NC_("dialogs-action", "Open the tool options dialog"),
"pika-tool-options",
PIKA_HELP_TOOL_OPTIONS_DIALOG },
{ "dialogs-device-status", PIKA_ICON_DIALOG_DEVICE_STATUS,
NC_("dialogs-action", "_Device Status Dialog"),
NC_("dialogs-action", "_Device Status"),
{ NULL },
NC_("dialogs-action", "Open the device status dialog"),
"pika-device-status",
PIKA_HELP_DEVICE_STATUS_DIALOG },
{ "dialogs-symmetry", PIKA_ICON_SYMMETRY,
NC_("dialogs-action", "_Symmetry Painting Dialog"),
NC_("dialogs-action", "_Symmetry Painting"),
{ NULL },
NC_("dialogs-action", "Open the symmetry dialog"),
"pika-symmetry-editor",
PIKA_HELP_SYMMETRY_DIALOG },
{ "dialogs-layers", PIKA_ICON_DIALOG_LAYERS,
NC_("dialogs-action", "_Layers Dialog"),
NC_("dialogs-action", "_Layers"),
{ "<primary>L", NULL },
NC_("dialogs-action", "Open the layers dialog"),
"pika-layer-list",
PIKA_HELP_LAYER_DIALOG },
{ "dialogs-channels", PIKA_ICON_DIALOG_CHANNELS,
NC_("dialogs-action", "_Channels Dialog"),
NC_("dialogs-action", "_Channels"),
{ NULL },
NC_("dialogs-action", "Open the channels dialog"),
"pika-channel-list",
PIKA_HELP_CHANNEL_DIALOG },
{ "dialogs-vectors", PIKA_ICON_DIALOG_PATHS,
NC_("dialogs-action", "_Paths Dialog"),
NC_("dialogs-action", "_Paths"),
{ NULL },
NC_("dialogs-action", "Open the paths dialog"),
"pika-vectors-list",
PIKA_HELP_PATH_DIALOG },
{ "dialogs-indexed-palette", PIKA_ICON_COLORMAP,
NC_("dialogs-action", "Color_map Dialog"),
NC_("dialogs-action", "Color_map"),
{ NULL },
NC_("dialogs-action", "Open the colormap dialog"),
"pika-indexed-palette",
PIKA_HELP_INDEXED_PALETTE_DIALOG },
{ "dialogs-histogram", PIKA_ICON_HISTOGRAM,
NC_("dialogs-action", "Histogra_m Dialog"),
NC_("dialogs-action", "Histogra_m"),
{ NULL },
NC_("dialogs-action", "Open the histogram dialog"),
"pika-histogram-editor",
PIKA_HELP_HISTOGRAM_DIALOG },
{ "dialogs-selection-editor", PIKA_ICON_SELECTION,
NC_("dialogs-action", "_Selection Editor"), NULL,
{ NULL },
NC_("dialogs-action", "Open the selection editor"),
"pika-selection-editor",
PIKA_HELP_SELECTION_DIALOG },
{ "dialogs-navigation", PIKA_ICON_DIALOG_NAVIGATION,
NC_("dialogs-action", "Na_vigation Dialog"),
NC_("dialogs-action", "Na_vigation"),
{ NULL },
NC_("dialogs-action", "Open the display navigation dialog"),
"pika-navigation-view",
PIKA_HELP_NAVIGATION_DIALOG },
{ "dialogs-undo-history", PIKA_ICON_DIALOG_UNDO_HISTORY,
NC_("dialogs-action", "Undo _History Dialog"),
NC_("dialogs-action", "Undo _History"),
{ NULL },
NC_("dialogs-action", "Open the undo history dialog"),
"pika-undo-history",
PIKA_HELP_UNDO_DIALOG },
{ "dialogs-cursor", PIKA_ICON_CURSOR,
NC_("dialogs-action", "_Pointer Dialog"),
NC_("dialogs-action", "_Pointer"),
{ NULL },
NC_("dialogs-action", "Open the pointer information dialog"),
"pika-cursor-view",
PIKA_HELP_POINTER_INFO_DIALOG },
{ "dialogs-sample-points", PIKA_ICON_SAMPLE_POINT,
NC_("dialogs-action", "_Sample Points Dialog"),
NC_("dialogs-action", "_Sample Points"),
{ NULL },
NC_("dialogs-action", "Open the sample points dialog"),
"pika-sample-point-editor",
PIKA_HELP_SAMPLE_POINT_DIALOG },
{ "dialogs-colors", PIKA_ICON_COLORS_DEFAULT,
NC_("dialogs-action", "Colo_rs Dialog"),
NC_("dialogs-action", "Colo_rs"),
{ NULL },
NC_("dialogs-action", "Open the FG/BG color dialog"),
"pika-color-editor",
PIKA_HELP_COLOR_DIALOG },
{ "dialogs-brushes", PIKA_ICON_BRUSH,
NC_("dialogs-action", "_Brushes Dialog"),
NC_("dialogs-action", "_Brushes"),
{ "<primary><shift>B", NULL },
NC_("dialogs-action", "Open the brushes dialog"),
"pika-brush-grid|pika-brush-list",
PIKA_HELP_BRUSH_DIALOG },
{ "dialogs-brush-editor", PIKA_ICON_BRUSH,
NC_("dialogs-action", "Brush Editor"), NULL,
{ NULL },
NC_("dialogs-action", "Open the brush editor"),
"pika-brush-editor",
PIKA_HELP_BRUSH_EDIT },
{ "dialogs-dynamics", PIKA_ICON_DYNAMICS,
NC_("dialogs-action", "Paint D_ynamics Dialog"),
NC_("dialogs-action", "Paint D_ynamics"),
{ NULL },
NC_("dialogs-action", "Open paint dynamics dialog"),
"pika-dynamics-list|pika-dynamics-grid",
PIKA_HELP_DYNAMICS_DIALOG },
{ "dialogs-dynamics-editor", PIKA_ICON_DYNAMICS,
NC_("dialogs-action", "Paint Dynamics Editor"), NULL,
{ NULL },
NC_("dialogs-action", "Open the paint dynamics editor"),
"pika-dynamics-editor",
PIKA_HELP_DYNAMICS_EDITOR_DIALOG },
{ "dialogs-mypaint-brushes", PIKA_ICON_MYPAINT_BRUSH,
NC_("dialogs-action", "_MyPaint Brushes Dialog"),
NC_("dialogs-action", "_MyPaint Brushes"),
{ NULL },
NC_("dialogs-action", "Open the mypaint brushes dialog"),
"pika-mypaint-brush-grid|pika-mapyint-brush-list",
PIKA_HELP_MYPAINT_BRUSH_DIALOG },
{ "dialogs-patterns", PIKA_ICON_PATTERN,
NC_("dialogs-action", "P_atterns Dialog"),
NC_("dialogs-action", "P_atterns"),
{ "<primary><shift>P", NULL },
NC_("dialogs-action", "Open the patterns dialog"),
"pika-pattern-grid|pika-pattern-list",
PIKA_HELP_PATTERN_DIALOG },
{ "dialogs-gradients", PIKA_ICON_GRADIENT,
NC_("dialogs-action", "_Gradients Dialog"),
NC_("dialogs-action", "_Gradients"),
{ "<primary>G", NULL },
NC_("dialogs-action", "Open the gradients dialog"),
"pika-gradient-list|pika-gradient-grid",
PIKA_HELP_GRADIENT_DIALOG },
{ "dialogs-gradient-editor", PIKA_ICON_GRADIENT,
NC_("dialogs-action", "Gradient Editor"), NULL,
{ NULL },
NC_("dialogs-action", "Open the gradient editor"),
"pika-gradient-editor",
PIKA_HELP_GRADIENT_EDIT },
{ "dialogs-palettes", PIKA_ICON_PALETTE,
NC_("dialogs-action", "Pal_ettes Dialog"),
NC_("dialogs-action", "Pal_ettes"),
{ NULL },
NC_("dialogs-action", "Open the palettes dialog"),
"pika-palette-list|pika-palette-grid",
PIKA_HELP_PALETTE_DIALOG },
{ "dialogs-palette-editor", PIKA_ICON_PALETTE,
NC_("dialogs-action", "Palette _Editor"),
NC_("dialogs-action", "Palette _Editor"),
{ NULL },
NC_("dialogs-action", "Open the palette editor"),
"pika-palette-editor",
PIKA_HELP_PALETTE_EDIT },
{ "dialogs-tool-presets", PIKA_ICON_TOOL_PRESET,
NC_("dialogs-action", "Tool Pre_sets Dialog"),
NC_("dialogs-action", "Tool Pre_sets"),
{ NULL },
NC_("dialogs-action", "Open tool presets dialog"),
"pika-tool-preset-list|pika-tool-preset-grid",
PIKA_HELP_TOOL_PRESET_DIALOG },
{ "dialogs-fonts", PIKA_ICON_FONT,
NC_("dialogs-action", "_Fonts Dialog"),
NC_("dialogs-action", "_Fonts"),
{ NULL },
NC_("dialogs-action", "Open the fonts dialog"),
"pika-font-list|pika-font-grid",
PIKA_HELP_FONT_DIALOG },
{ "dialogs-buffers", PIKA_ICON_BUFFER,
NC_("dialogs-action", "B_uffers Dialog"),
NC_("dialogs-action", "B_uffers"),
{ NULL },
NC_("dialogs-action", "Open the named buffers dialog"),
"pika-buffer-list|pika-buffer-grid",
PIKA_HELP_BUFFER_DIALOG },
{ "dialogs-images", PIKA_ICON_DIALOG_IMAGES,
NC_("dialogs-action", "_Images Dialog"),
NC_("dialogs-action", "_Images"),
{ NULL },
NC_("dialogs-action", "Open the images dialog"),
"pika-image-list|pika-image-grid",
PIKA_HELP_IMAGE_DIALOG },
{ "dialogs-document-history", PIKA_ICON_DOCUMENT_OPEN_RECENT,
NC_("dialogs-action", "Document Histor_y Dialog"),
NC_("dialogs-action", "Document Histor_y"),
{ NULL },
NC_("dialogs-action", "Open the document history dialog"),
"pika-document-list|pika-document-grid",
PIKA_HELP_DOCUMENT_DIALOG },
{ "dialogs-templates", PIKA_ICON_TEMPLATE,
NC_("dialogs-action", "_Templates Dialog"),
NC_("dialogs-action", "_Templates"),
{ NULL },
NC_("dialogs-action", "Open the image templates dialog"),
"pika-template-list|pika-template-grid",
PIKA_HELP_TEMPLATE_DIALOG },
{ "dialogs-error-console", PIKA_ICON_DIALOG_WARNING,
NC_("dialogs-action", "Error Co_nsole"),
NC_("dialogs-action", "Error Co_nsole"),
{ NULL },
NC_("dialogs-action", "Open the error console"),
"pika-error-console",
PIKA_HELP_ERRORS_DIALOG },
{ "dialogs-dashboard", PIKA_ICON_DIALOG_DASHBOARD,
NC_("dialogs-action", "_Dashboard"),
NC_("dialogs-action", "_Dashboard"),
{ NULL },
NC_("dialogs-action", "Open the dashboard"),
"pika-dashboard",
PIKA_HELP_ERRORS_DIALOG }
};
gint n_dialogs_dockable_actions = G_N_ELEMENTS (dialogs_dockable_actions);
static const PikaStringActionEntry dialogs_toplevel_actions[] =
{
{ "dialogs-preferences", PIKA_ICON_PREFERENCES_SYSTEM,
NC_("dialogs-action", "_Preferences"),
NC_("dialogs-action", "_Preferences"),
{ NULL },
NC_("dialogs-action", "Open the preferences dialog"),
"pika-preferences-dialog",
PIKA_HELP_PREFS_DIALOG },
{ "dialogs-input-devices", PIKA_ICON_INPUT_DEVICE,
NC_("dialogs-action", "_Input Devices Editor"),
NC_("dialogs-action", "_Input Devices"),
{ NULL },
NC_("dialogs-action", "Open the input devices editor"),
"pika-input-devices-dialog",
PIKA_HELP_INPUT_DEVICES },
{ "dialogs-keyboard-shortcuts", PIKA_ICON_CHAR_PICKER,
NC_("dialogs-action", "_Keyboard Shortcuts Editor"),
NC_("dialogs-action", "_Keyboard Shortcuts"),
{ NULL },
NC_("dialogs-action", "Open the keyboard shortcuts editor"),
"pika-keyboard-shortcuts-dialog",
PIKA_HELP_KEYBOARD_SHORTCUTS },
{ "dialogs-module-dialog", PIKA_ICON_SYSTEM_RUN,
NC_("dialogs-action", "_Modules Dialog"),
NC_("dialogs-action", "_Modules"),
{ NULL },
NC_("dialogs-action", "Open the module manager dialog"),
"pika-module-dialog",
PIKA_HELP_MODULE_DIALOG },
{ "dialogs-tips", PIKA_ICON_DIALOG_INFORMATION,
NC_("dialogs-action", "_Tip of the Day"), NULL,
{ NULL },
NC_("dialogs-action", "Show some helpful tips on using PIKA"),
"pika-tips-dialog",
PIKA_HELP_TIPS_DIALOG },
{ "dialogs-welcome", PIKA_ICON_DIALOG_INFORMATION,
NC_("dialogs-action", "Welcome Dialog"), NULL,
{ NULL },
NC_("dialogs-action", "Show information on running PIKA release"),
"pika-welcome-dialog",
PIKA_HELP_WELCOME_DIALOG },
{ "dialogs-about", PIKA_ICON_HELP_ABOUT,
#if defined(G_OS_WIN32)
NC_("dialogs-action", "About PIKA"),
#elif defined(PLATFORM_OSX)
NC_("dialogs-action", "About"),
#else /* UNIX: use GNOME HIG */
NC_("dialogs-action", "_About"),
#endif
NULL, { NULL },
NC_("dialogs-action", "About PIKA"),
"pika-about-dialog",
PIKA_HELP_ABOUT_DIALOG },
{ "dialogs-action-search", PIKA_ICON_TOOL_ZOOM,
NC_("dialogs-action", "_Search and Run a Command"), NULL,
{ "slash", "KP_Divide", NULL },
NC_("dialogs-action", "Search commands by keyword, and run them"),
"pika-action-search-dialog",
PIKA_HELP_ACTION_SEARCH_DIALOG },
{ "dialogs-extensions", PIKA_ICON_PLUGIN,
NC_("dialogs-action", "Manage _Extensions"), NULL,
{ NULL },
NC_("dialogs-action", "Manage Extensions: search, install, uninstall, update."),
"pika-extensions-dialog",
PIKA_HELP_EXTENSIONS_DIALOG }
};
gboolean
dialogs_actions_toolbox_exists (Pika *pika)
{
PikaDialogFactory *factory = pika_dialog_factory_get_singleton ();
gboolean toolbox_found = FALSE;
GList *iter;
/* First look in session managed windows */
toolbox_found =
pika_dialog_factory_find_widget (factory, "pika-toolbox-window") != NULL;
/* Then in image windows */
if (! toolbox_found)
{
GList *windows = pika ? pika_get_image_windows (pika) : NULL;
for (iter = windows; iter; iter = g_list_next (iter))
{
PikaImageWindow *window = PIKA_IMAGE_WINDOW (windows->data);
if (pika_image_window_has_toolbox (window))
{
toolbox_found = TRUE;
break;
}
}
g_list_free (windows);
}
return toolbox_found;
}
void
dialogs_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_string_actions (group, "dialogs-action",
dialogs_dockable_actions,
G_N_ELEMENTS (dialogs_dockable_actions),
dialogs_create_dockable_cmd_callback);
pika_action_group_add_string_actions (group, "dialogs-action",
dialogs_toplevel_actions,
G_N_ELEMENTS (dialogs_toplevel_actions),
dialogs_create_toplevel_cmd_callback);
}
void
dialogs_actions_update (PikaActionGroup *group,
gpointer data)
{
Pika *pika = action_data_get_pika (data);
const gchar *toolbox_label = NULL;
const gchar *toolbox_tooltip = NULL;
if (dialogs_actions_toolbox_exists (pika))
{
toolbox_label = _("Tool_box");
toolbox_tooltip = _("Raise the toolbox");
}
else
{
toolbox_label = _("New Tool_box");
toolbox_tooltip = _("Create a new toolbox");
}
pika_action_group_set_action_label (group, "dialogs-toolbox", toolbox_label);
pika_action_group_set_action_tooltip (group, "dialogs-toolbox", toolbox_tooltip);
}