Initial checkin of Pika from heckimp

This commit is contained in:
2023-09-25 15:35:21 -07:00
commit 891e999216
6761 changed files with 5240685 additions and 0 deletions

57
app/about.h Normal file
View File

@ -0,0 +1,57 @@
/* 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/>.
*/
#ifndef __ABOUT_H__
#define __ABOUT_H__
#define PIKA_ACRONYM \
_("PIKA")
#define PIKA_NAME \
_("Photo and Image Kooker Application")
/* The year of the last commit (UTC) will be inserted into this string. */
#define PIKA_COPYRIGHT \
_("Copyright ยฉ 1995-%s\n" \
"Based on work by Spencer Kimball, Peter Mattis and the GnuImp Development Team")
/* TRANSLATORS: do not end the license URL with a dot, because it would
* be in the link. Because of technical limitations, make sure the URL
* ends with a space, a newline or is end of text.
* Cf. bug 762282.
*/
#define PIKA_LICENSE \
_("PIKA 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." \
"\n\n" \
"PIKA 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." \
"\n\n" \
"You should have received a copy of the GNU General Public License " \
"along with PIKA. If not, see: https://www.gnu.org/licenses/")
#endif /* __ABOUT_H__ */

View File

@ -0,0 +1,58 @@
/* 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/>.
*/
#ifndef __ACTIONS_TYPES_H__
#define __ACTIONS_TYPES_H__
#include "dialogs/dialogs-types.h"
#include "tools/tools-types.h"
typedef enum
{
PIKA_ACTION_SELECT_SET = 0,
PIKA_ACTION_SELECT_SET_TO_DEFAULT = -1,
PIKA_ACTION_SELECT_FIRST = -2,
PIKA_ACTION_SELECT_LAST = -3,
PIKA_ACTION_SELECT_SMALL_PREVIOUS = -4,
PIKA_ACTION_SELECT_SMALL_NEXT = -5,
PIKA_ACTION_SELECT_PREVIOUS = -6,
PIKA_ACTION_SELECT_NEXT = -7,
PIKA_ACTION_SELECT_SKIP_PREVIOUS = -8,
PIKA_ACTION_SELECT_SKIP_NEXT = -9,
PIKA_ACTION_SELECT_PERCENT_PREVIOUS = -10,
PIKA_ACTION_SELECT_PERCENT_NEXT = -11
} PikaActionSelectType;
typedef enum
{
PIKA_SAVE_MODE_SAVE,
PIKA_SAVE_MODE_SAVE_AS,
PIKA_SAVE_MODE_SAVE_A_COPY,
PIKA_SAVE_MODE_SAVE_AND_CLOSE,
PIKA_SAVE_MODE_EXPORT,
PIKA_SAVE_MODE_EXPORT_AS,
PIKA_SAVE_MODE_OVERWRITE
} PikaSaveMode;
#endif /* __ACTIONS_TYPES_H__ */

775
app/actions/actions.c Normal file
View File

@ -0,0 +1,775 @@
/* 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 "core/pikacontainer.h"
#include "core/pikacontext.h"
#include "core/pikaimage.h"
#include "core/pikatooloptions.h"
#include "core/pikatoolinfo.h"
#include "widgets/pikaactionfactory.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikacontainereditor.h"
#include "widgets/pikacontainerview.h"
#include "widgets/pikadock.h"
#include "widgets/pikadockable.h"
#include "widgets/pikadockwindow.h"
#include "widgets/pikaimageeditor.h"
#include "widgets/pikaitemtreeview.h"
#include "display/pikadisplay.h"
#include "display/pikadisplayshell.h"
#include "display/pikaimagewindow.h"
#include "display/pikanavigationeditor.h"
#include "display/pikastatusbar.h"
#include "dialogs/dialogs.h"
#include "actions.h"
#include "brush-editor-actions.h"
#include "brushes-actions.h"
#include "buffers-actions.h"
#include "channels-actions.h"
#include "colormap-actions.h"
#include "context-actions.h"
#include "cursor-info-actions.h"
#include "dashboard-actions.h"
#include "debug-actions.h"
#include "dialogs-actions.h"
#include "dock-actions.h"
#include "dockable-actions.h"
#include "documents-actions.h"
#include "drawable-actions.h"
#include "dynamics-actions.h"
#include "dynamics-editor-actions.h"
#include "edit-actions.h"
#include "error-console-actions.h"
#include "file-actions.h"
#include "filters-actions.h"
#include "fonts-actions.h"
#include "gradient-editor-actions.h"
#include "gradients-actions.h"
#include "help-actions.h"
#include "image-actions.h"
#include "images-actions.h"
#include "layers-actions.h"
#include "mypaint-brushes-actions.h"
#include "palette-editor-actions.h"
#include "palettes-actions.h"
#include "patterns-actions.h"
#include "plug-in-actions.h"
#include "quick-mask-actions.h"
#include "sample-points-actions.h"
#include "select-actions.h"
#include "templates-actions.h"
#include "text-editor-actions.h"
#include "text-tool-actions.h"
#include "tool-options-actions.h"
#include "tool-presets-actions.h"
#include "tool-preset-editor-actions.h"
#include "tools-actions.h"
#include "vector-toolpath-actions.h"
#include "vectors-actions.h"
#include "view-actions.h"
#include "windows-actions.h"
#include "pika-intl.h"
/* global variables */
PikaActionFactory *global_action_factory = NULL;
/* private variables */
static const PikaActionFactoryEntry action_groups[] =
{
{ "brush-editor", N_("Brush Editor"), PIKA_ICON_BRUSH,
brush_editor_actions_setup,
brush_editor_actions_update },
{ "brushes", N_("Brushes"), PIKA_ICON_BRUSH,
brushes_actions_setup,
brushes_actions_update },
{ "buffers", N_("Buffers"), PIKA_ICON_BUFFER,
buffers_actions_setup,
buffers_actions_update },
{ "channels", N_("Channels"), PIKA_ICON_CHANNEL,
channels_actions_setup,
channels_actions_update },
{ "colormap", N_("Colormap"), PIKA_ICON_COLORMAP,
colormap_actions_setup,
colormap_actions_update },
{ "context", N_("Context"), PIKA_ICON_DIALOG_TOOL_OPTIONS /* well... */,
context_actions_setup,
context_actions_update },
{ "cursor-info", N_("Pointer Information"), NULL,
cursor_info_actions_setup,
cursor_info_actions_update },
{ "dashboard", N_("Dashboard"), PIKA_ICON_DIALOG_DASHBOARD,
dashboard_actions_setup,
dashboard_actions_update },
{ "debug", N_("Debug"), NULL,
debug_actions_setup,
debug_actions_update },
{ "dialogs", N_("Dialogs"), NULL,
dialogs_actions_setup,
dialogs_actions_update },
{ "dock", N_("Dock"), NULL,
dock_actions_setup,
dock_actions_update },
{ "dockable", N_("Dockable"), NULL,
dockable_actions_setup,
dockable_actions_update },
{ "documents", N_("Document History"), NULL,
documents_actions_setup,
documents_actions_update },
{ "drawable", N_("Drawable"), PIKA_ICON_LAYER,
drawable_actions_setup,
drawable_actions_update },
{ "dynamics", N_("Paint Dynamics"), PIKA_ICON_DYNAMICS,
dynamics_actions_setup,
dynamics_actions_update },
{ "dynamics-editor", N_("Paint Dynamics Editor"), PIKA_ICON_DYNAMICS,
dynamics_editor_actions_setup,
dynamics_editor_actions_update },
{ "edit", N_("Edit"), PIKA_ICON_EDIT,
edit_actions_setup,
edit_actions_update },
{ "error-console", N_("Error Console"), PIKA_ICON_DIALOG_WARNING,
error_console_actions_setup,
error_console_actions_update },
{ "file", N_("File"), "text-x-generic",
file_actions_setup,
file_actions_update },
{ "filters", N_("Filters"), PIKA_ICON_GEGL,
filters_actions_setup,
filters_actions_update },
{ "fonts", N_("Fonts"), PIKA_ICON_FONT,
fonts_actions_setup,
fonts_actions_update },
{ "gradient-editor", N_("Gradient Editor"), PIKA_ICON_GRADIENT,
gradient_editor_actions_setup,
gradient_editor_actions_update },
{ "gradients", N_("Gradients"), PIKA_ICON_GRADIENT,
gradients_actions_setup,
gradients_actions_update },
{ "tool-presets", N_("Tool Presets"), PIKA_ICON_TOOL_PRESET,
tool_presets_actions_setup,
tool_presets_actions_update },
{ "tool-preset-editor", N_("Tool Preset Editor"), PIKA_ICON_TOOL_PRESET,
tool_preset_editor_actions_setup,
tool_preset_editor_actions_update },
{ "help", N_("Help"), "help-browser",
help_actions_setup,
help_actions_update },
{ "image", N_("Image"), PIKA_ICON_IMAGE,
image_actions_setup,
image_actions_update },
{ "images", N_("Images"), PIKA_ICON_IMAGE,
images_actions_setup,
images_actions_update },
{ "layers", N_("Layers"), PIKA_ICON_LAYER,
layers_actions_setup,
layers_actions_update },
{ "mypaint-brushes", N_("MyPaint Brushes"), PIKA_ICON_MYPAINT_BRUSH,
mypaint_brushes_actions_setup,
mypaint_brushes_actions_update },
{ "palette-editor", N_("Palette Editor"), PIKA_ICON_PALETTE,
palette_editor_actions_setup,
palette_editor_actions_update },
{ "palettes", N_("Palettes"), PIKA_ICON_PALETTE,
palettes_actions_setup,
palettes_actions_update },
{ "patterns", N_("Patterns"), PIKA_ICON_PATTERN,
patterns_actions_setup,
patterns_actions_update },
{ "plug-in", N_("Plug-ins"), PIKA_ICON_PLUGIN,
plug_in_actions_setup,
plug_in_actions_update },
{ "quick-mask", N_("Quick Mask"), PIKA_ICON_QUICK_MASK_ON,
quick_mask_actions_setup,
quick_mask_actions_update },
{ "sample-points", N_("Sample Points"), PIKA_ICON_SAMPLE_POINT,
sample_points_actions_setup,
sample_points_actions_update },
{ "select", N_("Select"), PIKA_ICON_SELECTION,
select_actions_setup,
select_actions_update },
{ "templates", N_("Templates"), PIKA_ICON_TEMPLATE,
templates_actions_setup,
templates_actions_update },
{ "text-tool", N_("Text Tool"), PIKA_ICON_EDIT,
text_tool_actions_setup,
text_tool_actions_update },
{ "text-editor", N_("Text Editor"), PIKA_ICON_EDIT,
text_editor_actions_setup,
text_editor_actions_update },
{ "tool-options", N_("Tool Options"), PIKA_ICON_DIALOG_TOOL_OPTIONS,
tool_options_actions_setup,
tool_options_actions_update },
{ "tools", N_("Tools"), PIKA_ICON_DIALOG_TOOLS,
tools_actions_setup,
tools_actions_update },
{ "vector-toolpath", N_("Path Toolpath"), PIKA_ICON_PATH,
vector_toolpath_actions_setup,
vector_toolpath_actions_update },
{ "vectors", N_("Paths"), PIKA_ICON_PATH,
vectors_actions_setup,
vectors_actions_update },
{ "view", N_("View"), PIKA_ICON_VISIBLE,
view_actions_setup,
view_actions_update },
{ "windows", N_("Windows"), NULL,
windows_actions_setup,
windows_actions_update }
};
/* public functions */
void
actions_init (Pika *pika)
{
gint i;
g_return_if_fail (PIKA_IS_PIKA (pika));
g_return_if_fail (global_action_factory == NULL);
global_action_factory = pika_action_factory_new (pika);
for (i = 0; i < G_N_ELEMENTS (action_groups); i++)
pika_action_factory_group_register (global_action_factory,
action_groups[i].identifier,
gettext (action_groups[i].label),
action_groups[i].icon_name,
action_groups[i].setup_func,
action_groups[i].update_func);
}
void
actions_exit (Pika *pika)
{
g_return_if_fail (PIKA_IS_PIKA (pika));
g_return_if_fail (global_action_factory != NULL);
g_return_if_fail (global_action_factory->pika == pika);
g_clear_object (&global_action_factory);
}
Pika *
action_data_get_pika (gpointer data)
{
Pika *result = NULL;
static gboolean recursion = FALSE;
if (! data || recursion)
return NULL;
recursion = TRUE;
if (PIKA_IS_PIKA (data))
result = data;
if (! result)
{
PikaDisplay *display = action_data_get_display (data);
if (display)
result = display->pika;
}
if (! result)
{
PikaContext *context = action_data_get_context (data);
if (context)
result = context->pika;
}
recursion = FALSE;
return result;
}
PikaContext *
action_data_get_context (gpointer data)
{
PikaContext *result = NULL;
static gboolean recursion = FALSE;
if (! data || recursion)
return NULL;
recursion = TRUE;
if (PIKA_IS_DOCK (data))
result = pika_dock_get_context ((PikaDock *) data);
else if (PIKA_IS_DOCK_WINDOW (data))
result = pika_dock_window_get_context (((PikaDockWindow *) data));
else if (PIKA_IS_CONTAINER_VIEW (data))
result = pika_container_view_get_context ((PikaContainerView *) data);
else if (PIKA_IS_CONTAINER_EDITOR (data))
result = pika_container_view_get_context (((PikaContainerEditor *) data)->view);
else if (PIKA_IS_IMAGE_EDITOR (data))
result = ((PikaImageEditor *) data)->context;
else if (PIKA_IS_NAVIGATION_EDITOR (data))
result = ((PikaNavigationEditor *) data)->context;
if (! result)
{
Pika *pika = action_data_get_pika (data);
if (pika)
result = pika_get_user_context (pika);
}
recursion = FALSE;
return result;
}
PikaImage *
action_data_get_image (gpointer data)
{
PikaImage *result = NULL;
static gboolean recursion = FALSE;
if (! data || recursion)
return NULL;
recursion = TRUE;
if (PIKA_IS_ITEM_TREE_VIEW (data))
{
result = pika_item_tree_view_get_image ((PikaItemTreeView *) data);
recursion = FALSE;
return result;
}
else if (PIKA_IS_IMAGE_EDITOR (data))
{
result = ((PikaImageEditor *) data)->image;
recursion = FALSE;
return result;
}
if (! result)
{
PikaDisplay *display = action_data_get_display (data);
if (display)
result = pika_display_get_image (display);
}
if (! result)
{
PikaContext *context = action_data_get_context (data);
if (context)
result = pika_context_get_image (context);
}
recursion = FALSE;
return result;
}
PikaDisplay *
action_data_get_display (gpointer data)
{
PikaDisplay *result = NULL;
static gboolean recursion = FALSE;
if (! data || recursion)
return NULL;
recursion = TRUE;
if (PIKA_IS_DISPLAY (data))
result = data;
else if (PIKA_IS_IMAGE_WINDOW (data))
{
PikaDisplayShell *shell = pika_image_window_get_active_shell (data);
result = shell ? shell->display : NULL;
}
if (! result)
{
PikaContext *context = action_data_get_context (data);
if (context)
result = pika_context_get_display (context);
}
recursion = FALSE;
return result;
}
PikaDisplayShell *
action_data_get_shell (gpointer data)
{
PikaDisplayShell *result = NULL;
static gboolean recursion = FALSE;
if (! data || recursion)
return NULL;
recursion = TRUE;
if (! result)
{
PikaDisplay *display = action_data_get_display (data);
if (display)
result = pika_display_get_shell (display);
}
recursion = FALSE;
return result;
}
GtkWidget *
action_data_get_widget (gpointer data)
{
GtkWidget *result = NULL;
static gboolean recursion = FALSE;
if (! data || recursion)
return NULL;
recursion = TRUE;
if (GTK_IS_WIDGET (data))
result = data;
if (! result)
{
PikaDisplay *display = action_data_get_display (data);
if (display)
result = GTK_WIDGET (pika_display_get_shell (display));
}
if (! result)
result = dialogs_get_toolbox ();
recursion = FALSE;
return result;
}
gint
action_data_sel_count (gpointer data)
{
if (PIKA_IS_CONTAINER_EDITOR (data))
{
PikaContainerEditor *editor;
editor = PIKA_CONTAINER_EDITOR (data);
return pika_container_view_get_selected (editor->view, NULL, NULL);
}
else
{
return 0;
}
}
/* action_select_value:
* @select_type:
* @value:
* @min:
* max:
* def:
* small_inc:
* inc:
* skip_inc:
* delta_factor:
* wrap:
*
* For any valid enum @value (which are all negative), the corresponding
* action computes the semantic value (default, first, next, etc.).
* For a positive @value, it is considered as a per-thousand value
* between the @min and @max (possibly wrapped if @wrap is set, clamped
* otherwise), allowing to compute the returned value.
*
* Returns: the computed value to use for the action.
*/
gdouble
action_select_value (PikaActionSelectType select_type,
gdouble value,
gdouble min,
gdouble max,
gdouble def,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gdouble delta_factor,
gboolean wrap)
{
switch (select_type)
{
case PIKA_ACTION_SELECT_SET_TO_DEFAULT:
value = def;
break;
case PIKA_ACTION_SELECT_FIRST:
value = min;
break;
case PIKA_ACTION_SELECT_LAST:
value = max;
break;
case PIKA_ACTION_SELECT_SMALL_PREVIOUS:
value -= small_inc;
break;
case PIKA_ACTION_SELECT_SMALL_NEXT:
value += small_inc;
break;
case PIKA_ACTION_SELECT_PREVIOUS:
value -= inc;
break;
case PIKA_ACTION_SELECT_NEXT:
value += inc;
break;
case PIKA_ACTION_SELECT_SKIP_PREVIOUS:
value -= skip_inc;
break;
case PIKA_ACTION_SELECT_SKIP_NEXT:
value += skip_inc;
break;
case PIKA_ACTION_SELECT_PERCENT_PREVIOUS:
g_return_val_if_fail (delta_factor >= 0.0, value);
value /= (1.0 + delta_factor);
break;
case PIKA_ACTION_SELECT_PERCENT_NEXT:
g_return_val_if_fail (delta_factor >= 0.0, value);
value *= (1.0 + delta_factor);
break;
default:
if ((gint) select_type >= 0)
value = (gdouble) select_type * (max - min) / 1000.0 + min;
else
g_return_val_if_reached (value);
break;
}
if (wrap)
{
while (value < min)
value = max - (min - value);
while (value > max)
value = min + (value - max);
}
else
{
value = CLAMP (value, min, max);
}
return value;
}
void
action_select_property (PikaActionSelectType select_type,
PikaDisplay *display,
GObject *object,
const gchar *property_name,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gdouble delta_factor,
gboolean wrap)
{
GParamSpec *pspec;
g_return_if_fail (display == NULL || PIKA_IS_DISPLAY (display));
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (property_name != NULL);
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object),
property_name);
if (G_IS_PARAM_SPEC_DOUBLE (pspec))
{
gdouble value;
g_object_get (object, property_name, &value, NULL);
value = action_select_value (select_type,
value,
G_PARAM_SPEC_DOUBLE (pspec)->minimum,
G_PARAM_SPEC_DOUBLE (pspec)->maximum,
G_PARAM_SPEC_DOUBLE (pspec)->default_value,
small_inc, inc, skip_inc, delta_factor, wrap);
g_object_set (object, property_name, value, NULL);
if (display)
{
const gchar *blurb = g_param_spec_get_blurb (pspec);
if (blurb)
{
/* value description and new value shown in the status bar */
action_message (display, object, _("%s: %.2f"), blurb, value);
}
}
}
else if (G_IS_PARAM_SPEC_INT (pspec))
{
gint value;
g_object_get (object, property_name, &value, NULL);
value = action_select_value (select_type,
value,
G_PARAM_SPEC_INT (pspec)->minimum,
G_PARAM_SPEC_INT (pspec)->maximum,
G_PARAM_SPEC_INT (pspec)->default_value,
small_inc, inc, skip_inc, delta_factor, wrap);
g_object_set (object, property_name, value, NULL);
if (display)
{
const gchar *blurb = g_param_spec_get_blurb (pspec);
if (blurb)
{
/* value description and new value shown in the status bar */
action_message (display, object, _("%s: %d"), blurb, value);
}
}
}
else
{
g_return_if_reached ();
}
}
PikaObject *
action_select_object (PikaActionSelectType select_type,
PikaContainer *container,
PikaObject *current)
{
gint select_index;
gint n_children;
g_return_val_if_fail (PIKA_IS_CONTAINER (container), NULL);
g_return_val_if_fail (current == NULL || PIKA_IS_OBJECT (current), NULL);
if (! current &&
select_type != PIKA_ACTION_SELECT_FIRST &&
select_type != PIKA_ACTION_SELECT_LAST)
return NULL;
n_children = pika_container_get_n_children (container);
if (n_children == 0)
return NULL;
switch (select_type)
{
case PIKA_ACTION_SELECT_FIRST:
select_index = 0;
break;
case PIKA_ACTION_SELECT_LAST:
select_index = n_children - 1;
break;
case PIKA_ACTION_SELECT_PREVIOUS:
select_index = pika_container_get_child_index (container, current) - 1;
break;
case PIKA_ACTION_SELECT_NEXT:
select_index = pika_container_get_child_index (container, current) + 1;
break;
case PIKA_ACTION_SELECT_SKIP_PREVIOUS:
select_index = pika_container_get_child_index (container, current) - 10;
break;
case PIKA_ACTION_SELECT_SKIP_NEXT:
select_index = pika_container_get_child_index (container, current) + 10;
break;
default:
if ((gint) select_type >= 0)
select_index = (gint) select_type;
else
g_return_val_if_reached (current);
break;
}
select_index = CLAMP (select_index, 0, n_children - 1);
return pika_container_get_child_by_index (container, select_index);
}
void
action_message (PikaDisplay *display,
GObject *object,
const gchar *format,
...)
{
PikaDisplayShell *shell = pika_display_get_shell (display);
PikaStatusbar *statusbar = pika_display_shell_get_statusbar (shell);
const gchar *icon_name = NULL;
va_list args;
if (PIKA_IS_TOOL_OPTIONS (object))
{
PikaToolInfo *tool_info = PIKA_TOOL_OPTIONS (object)->tool_info;
icon_name = pika_viewable_get_icon_name (PIKA_VIEWABLE (tool_info));
}
else if (PIKA_IS_VIEWABLE (object))
{
icon_name = pika_viewable_get_icon_name (PIKA_VIEWABLE (object));
}
va_start (args, format);
pika_statusbar_push_temp_valist (statusbar, PIKA_MESSAGE_INFO,
icon_name, format, args);
va_end (args);
}

123
app/actions/actions.h Normal file
View File

@ -0,0 +1,123 @@
/* 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/>.
*/
#ifndef __ACTIONS_H__
#define __ACTIONS_H__
extern PikaActionFactory *global_action_factory;
void actions_init (Pika *pika);
void actions_exit (Pika *pika);
Pika * action_data_get_pika (gpointer data);
PikaContext * action_data_get_context (gpointer data);
PikaImage * action_data_get_image (gpointer data);
PikaDisplay * action_data_get_display (gpointer data);
PikaDisplayShell * action_data_get_shell (gpointer data);
GtkWidget * action_data_get_widget (gpointer data);
gint action_data_sel_count (gpointer data);
gdouble action_select_value (PikaActionSelectType select_type,
gdouble value,
gdouble min,
gdouble max,
gdouble def,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gdouble delta_factor,
gboolean wrap);
void action_select_property (PikaActionSelectType select_type,
PikaDisplay *display,
GObject *object,
const gchar *property_name,
gdouble small_inc,
gdouble inc,
gdouble skip_inc,
gdouble delta_factor,
gboolean wrap);
PikaObject * action_select_object (PikaActionSelectType select_type,
PikaContainer *container,
PikaObject *current);
void action_message (PikaDisplay *display,
GObject *object,
const gchar *format,
...) G_GNUC_PRINTF(3,4);
#define return_if_no_pika(pika,data) \
pika = action_data_get_pika (data); \
if (! pika) \
return
#define return_if_no_context(context,data) \
context = action_data_get_context (data); \
if (! context) \
return
#define return_if_no_image(image,data) \
image = action_data_get_image (data); \
if (! image) \
return
#define return_if_no_display(display,data) \
display = action_data_get_display (data); \
if (! display) \
return
#define return_if_no_shell(shell,data) \
shell = action_data_get_shell (data); \
if (! shell) \
return
#define return_if_no_widget(widget,data) \
widget = action_data_get_widget (data); \
if (! widget) \
return
#define return_if_no_drawables(image,drawables,data) \
return_if_no_image (image,data); \
drawables = pika_image_get_selected_drawables (image); \
if (! drawables) \
return
#define return_if_no_layers(image,layers,data) \
return_if_no_image (image,data); \
layers = pika_image_get_selected_layers (image); \
if (! layers) \
return
#define return_if_no_channels(image,channels,data) \
return_if_no_image (image,data); \
channels = pika_image_get_selected_channels (image); \
if (! channels) \
return
#define return_if_no_vectors_list(image,list,data) \
return_if_no_image (image,data); \
list = pika_image_get_selected_vectors (image); \
if (! list) \
return
#endif /* __ACTIONS_H__ */

View File

@ -0,0 +1,80 @@
/* 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 "core/pikacontext.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikahelp-ids.h"
#include "widgets/pikabrusheditor.h"
#include "brush-editor-actions.h"
#include "data-editor-commands.h"
#include "pika-intl.h"
static const PikaToggleActionEntry brush_editor_toggle_actions[] =
{
{ "brush-editor-edit-active", PIKA_ICON_LINKED,
NC_("brush-editor-action", "Edit Active Brush"), NULL, { NULL }, NULL,
data_editor_edit_active_cmd_callback,
FALSE,
PIKA_HELP_BRUSH_EDITOR_EDIT_ACTIVE }
};
void
brush_editor_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_toggle_actions (group, "brush-editor-action",
brush_editor_toggle_actions,
G_N_ELEMENTS (brush_editor_toggle_actions));
}
void
brush_editor_actions_update (PikaActionGroup *group,
gpointer user_data)
{
PikaDataEditor *data_editor = PIKA_DATA_EDITOR (user_data);
gboolean edit_active = FALSE;
edit_active = pika_data_editor_get_edit_active (data_editor);
#define SET_SENSITIVE(action,condition) \
pika_action_group_set_action_sensitive (group, action, (condition) != 0)
#define SET_ACTIVE(action,condition) \
pika_action_group_set_action_active (group, action, (condition) != 0)
SET_ACTIVE ("brush-editor-edit-active", edit_active);
#undef SET_SENSITIVE
#undef SET_ACTIVE
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __BRUSH_EDITOR_ACTIONS_H__
#define __BRUSH_EDITOR_ACTIONS_H__
void brush_editor_actions_setup (PikaActionGroup *group);
void brush_editor_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __BRUSH_EDITOR_ACTIONS_H__ */

View File

@ -0,0 +1,149 @@
/* 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/pikabrushgenerated.h"
#include "core/pikacontext.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikahelp-ids.h"
#include "actions.h"
#include "brushes-actions.h"
#include "data-commands.h"
#include "pika-intl.h"
static const PikaActionEntry brushes_actions[] =
{
{ "brushes-open-as-image", PIKA_ICON_DOCUMENT_OPEN,
NC_("brushes-action", "_Open Brush as Image"), NULL, { NULL },
NC_("brushes-action", "Open brush as image"),
data_open_as_image_cmd_callback,
PIKA_HELP_BRUSH_OPEN_AS_IMAGE },
{ "brushes-new", PIKA_ICON_DOCUMENT_NEW,
NC_("brushes-action", "_New Brush"), NULL, { NULL },
NC_("brushes-action", "Create a new brush"),
data_new_cmd_callback,
PIKA_HELP_BRUSH_NEW },
{ "brushes-duplicate", PIKA_ICON_OBJECT_DUPLICATE,
NC_("brushes-action", "D_uplicate Brush"), NULL, { NULL },
NC_("brushes-action", "Duplicate this brush"),
data_duplicate_cmd_callback,
PIKA_HELP_BRUSH_DUPLICATE },
{ "brushes-copy-location", PIKA_ICON_EDIT_COPY,
NC_("brushes-action", "Copy Brush _Location"), NULL, { NULL },
NC_("brushes-action", "Copy brush file location to clipboard"),
data_copy_location_cmd_callback,
PIKA_HELP_BRUSH_COPY_LOCATION },
{ "brushes-show-in-file-manager", PIKA_ICON_FILE_MANAGER,
NC_("brushes-action", "Show in _File Manager"), NULL, { NULL },
NC_("brushes-action", "Show brush file location in the file manager"),
data_show_in_file_manager_cmd_callback,
PIKA_HELP_BRUSH_SHOW_IN_FILE_MANAGER },
{ "brushes-delete", PIKA_ICON_EDIT_DELETE,
NC_("brushes-action", "_Delete Brush"), NULL, { NULL },
NC_("brushes-action", "Delete this brush"),
data_delete_cmd_callback,
PIKA_HELP_BRUSH_DELETE },
{ "brushes-refresh", PIKA_ICON_VIEW_REFRESH,
NC_("brushes-action", "_Refresh Brushes"), NULL, { NULL },
NC_("brushes-action", "Refresh brushes"),
data_refresh_cmd_callback,
PIKA_HELP_BRUSH_REFRESH }
};
static const PikaStringActionEntry brushes_edit_actions[] =
{
{ "brushes-edit", PIKA_ICON_EDIT,
NC_("brushes-action", "_Edit Brush..."), NULL, { NULL },
NC_("brushes-action", "Edit this brush"),
"pika-brush-editor",
PIKA_HELP_BRUSH_EDIT }
};
void
brushes_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_actions (group, "brushes-action",
brushes_actions,
G_N_ELEMENTS (brushes_actions));
pika_action_group_add_string_actions (group, "brushes-action",
brushes_edit_actions,
G_N_ELEMENTS (brushes_edit_actions),
data_edit_cmd_callback);
}
void
brushes_actions_update (PikaActionGroup *group,
gpointer user_data)
{
PikaContext *context = action_data_get_context (user_data);
PikaBrush *brush = NULL;
PikaData *data = NULL;
GFile *file = NULL;
if (context)
{
brush = pika_context_get_brush (context);
if (action_data_sel_count (user_data) > 1)
{
brush = NULL;
}
if (brush)
{
data = PIKA_DATA (brush);
file = pika_data_get_file (data);
}
}
#define SET_SENSITIVE(action,condition) \
pika_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)
SET_SENSITIVE ("brushes-edit", brush);
SET_SENSITIVE ("brushes-open-as-image", file && ! PIKA_IS_BRUSH_GENERATED (brush));
SET_SENSITIVE ("brushes-duplicate", brush && pika_data_is_duplicatable (data));
SET_SENSITIVE ("brushes-copy-location", file);
SET_SENSITIVE ("brushes-show-in-file-manager", file);
SET_SENSITIVE ("brushes-delete", brush && pika_data_is_deletable (data));
#undef SET_SENSITIVE
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __BRUSHES_ACTIONS_H__
#define __BRUSHES_ACTIONS_H__
void brushes_actions_setup (PikaActionGroup *group);
void brushes_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __BRUSHES_ACTIONS_H__ */

View File

@ -0,0 +1,136 @@
/* 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/pikacontext.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikahelp-ids.h"
#include "actions.h"
#include "buffers-actions.h"
#include "buffers-commands.h"
#include "pika-intl.h"
static const PikaActionEntry buffers_actions[] =
{
{ "buffers-paste-as-new-image", PIKA_ICON_EDIT_PASTE_AS_NEW,
NC_("buffers-action", "Paste Buffer as _New Image"), NULL, { NULL },
NC_("buffers-action", "Paste the selected buffer as a new image"),
buffers_paste_as_new_image_cmd_callback,
PIKA_HELP_BUFFER_PASTE_AS_NEW_IMAGE },
{ "buffers-delete", PIKA_ICON_EDIT_DELETE,
NC_("buffers-action", "_Delete Buffer"), NULL, { NULL },
NC_("buffers-action", "Delete the selected buffer"),
buffers_delete_cmd_callback,
PIKA_HELP_BUFFER_DELETE }
};
static const PikaEnumActionEntry buffers_paste_actions[] =
{
{ "buffers-paste", PIKA_ICON_EDIT_PASTE,
NC_("buffers-action", "_Paste Buffer"), NULL, { NULL },
NC_("buffers-action", "Paste the selected buffer"),
PIKA_PASTE_TYPE_FLOATING, FALSE,
PIKA_HELP_BUFFER_PASTE },
{ "buffers-paste-in-place", PIKA_ICON_EDIT_PASTE,
NC_("buffers-action", "Paste Buffer In Pl_ace"), NULL, { NULL },
NC_("buffers-action", "Paste the selected buffer at its original position"),
PIKA_PASTE_TYPE_FLOATING_IN_PLACE, FALSE,
PIKA_HELP_BUFFER_PASTE_IN_PLACE },
{ "buffers-paste-into", PIKA_ICON_EDIT_PASTE_INTO,
NC_("buffers-action", "Paste Buffer _Into The Selection"), NULL, { NULL },
NC_("buffers-action", "Paste the selected buffer into the selection"),
PIKA_PASTE_TYPE_FLOATING_INTO, FALSE,
PIKA_HELP_BUFFER_PASTE_INTO },
{ "buffers-paste-into-in-place", PIKA_ICON_EDIT_PASTE_INTO,
NC_("buffers-action", "Paste Buffer Into The Selection In Place"), NULL, { NULL },
NC_("buffers-action",
"Paste the selected buffer into the selection at its original position"),
PIKA_PASTE_TYPE_FLOATING_INTO_IN_PLACE, FALSE,
PIKA_HELP_BUFFER_PASTE_INTO_IN_PLACE },
{ "buffers-paste-as-new-layer", PIKA_ICON_EDIT_PASTE_AS_NEW,
NC_("buffers-action", "Paste Buffer as New _Layer"), NULL, { NULL },
NC_("buffers-action", "Paste the selected buffer as a new layer"),
PIKA_PASTE_TYPE_NEW_LAYER, FALSE,
PIKA_HELP_BUFFER_PASTE_AS_NEW_LAYER },
{ "buffers-paste-as-new-layer-in-place", PIKA_ICON_EDIT_PASTE_AS_NEW,
NC_("buffers-action", "Paste Buffer as New Layer in Place"), NULL, { NULL },
NC_("buffers-action",
"Paste the selected buffer as a new layer at its original position"),
PIKA_PASTE_TYPE_NEW_LAYER_IN_PLACE, FALSE,
PIKA_HELP_BUFFER_PASTE_AS_NEW_LAYER_IN_PLACE },
};
void
buffers_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_actions (group, "buffers-action",
buffers_actions,
G_N_ELEMENTS (buffers_actions));
pika_action_group_add_enum_actions (group, "buffers-action",
buffers_paste_actions,
G_N_ELEMENTS (buffers_paste_actions),
buffers_paste_cmd_callback);
}
void
buffers_actions_update (PikaActionGroup *group,
gpointer data)
{
PikaContext *context = action_data_get_context (data);
PikaBuffer *buffer = NULL;
if (context)
buffer = pika_context_get_buffer (context);
#define SET_SENSITIVE(action,condition,reason) \
pika_action_group_set_action_sensitive (group, action, (condition) != 0, reason)
SET_SENSITIVE ("buffers-paste", buffer, _("No selected buffer"));
SET_SENSITIVE ("buffers-paste-in-place", buffer, _("No selected buffer"));
SET_SENSITIVE ("buffers-paste-into", buffer, _("No selected buffer"));
SET_SENSITIVE ("buffers-paste-into-in-place", buffer, _("No selected buffer"));
SET_SENSITIVE ("buffers-paste-as-new-layer", buffer, _("No selected buffer"));
SET_SENSITIVE ("buffers-paste-as-new-layer-in-place", buffer, _("No selected buffer"));
SET_SENSITIVE ("buffers-paste-as-new-image", buffer, _("No selected buffer"));
SET_SENSITIVE ("buffers-delete", buffer, _("No selected buffer"));
#undef SET_SENSITIVE
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __BUFFERS_ACTIONS_H__
#define __BUFFERS_ACTIONS_H__
void buffers_actions_setup (PikaActionGroup *group);
void buffers_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __BUFFERS_ACTIONS_H__ */

View File

@ -0,0 +1,146 @@
/* 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 "core/pika-edit.h"
#include "core/pikacontainer.h"
#include "core/pikacontext.h"
#include "core/pikaimage.h"
#include "widgets/pikacontainereditor.h"
#include "widgets/pikacontainerview.h"
#include "widgets/pikacontainerview-utils.h"
#include "display/pikadisplay.h"
#include "display/pikadisplayshell.h"
#include "display/pikadisplayshell-transform.h"
#include "buffers-commands.h"
#include "pika-intl.h"
/* public functions */
void
buffers_paste_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaContainerEditor *editor = PIKA_CONTAINER_EDITOR (data);
PikaContainer *container;
PikaContext *context;
PikaBuffer *buffer;
PikaPasteType paste_type = (PikaPasteType) g_variant_get_int32 (value);
container = pika_container_view_get_container (editor->view);
context = pika_container_view_get_context (editor->view);
buffer = pika_context_get_buffer (context);
if (buffer && pika_container_have (container, PIKA_OBJECT (buffer)))
{
PikaDisplay *display = pika_context_get_display (context);
PikaImage *image = NULL;
gint x = -1;
gint y = -1;
gint width = -1;
gint height = -1;
if (display)
{
PikaDisplayShell *shell = pika_display_get_shell (display);
pika_display_shell_untransform_viewport (
shell,
! pika_display_shell_get_infinite_canvas (shell),
&x, &y, &width, &height);
image = pika_display_get_image (display);
}
else
{
image = pika_context_get_image (context);
}
if (image)
{
GList *drawables = pika_image_get_selected_drawables (image);
g_list_free (pika_edit_paste (image, drawables,
PIKA_OBJECT (buffer), paste_type,
context, FALSE,
x, y, width, height));
pika_image_flush (image);
g_list_free (drawables);
}
}
}
void
buffers_paste_as_new_image_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaContainerEditor *editor = PIKA_CONTAINER_EDITOR (data);
PikaContainer *container;
PikaContext *context;
PikaBuffer *buffer;
container = pika_container_view_get_container (editor->view);
context = pika_container_view_get_context (editor->view);
buffer = pika_context_get_buffer (context);
if (buffer && pika_container_have (container, PIKA_OBJECT (buffer)))
{
GtkWidget *widget = GTK_WIDGET (editor);
PikaImage *new_image;
new_image = pika_edit_paste_as_new_image (context->pika,
PIKA_OBJECT (buffer),
context);
pika_create_display (context->pika, new_image,
PIKA_UNIT_PIXEL, 1.0,
G_OBJECT (pika_widget_get_monitor (widget)));
g_object_unref (new_image);
}
}
void
buffers_delete_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaContainerEditor *editor = PIKA_CONTAINER_EDITOR (data);
pika_container_view_remove_active (editor->view);
}

View File

@ -0,0 +1,37 @@
/* 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/>.
*/
#ifndef __BUFFERS_COMMANDS_H__
#define __BUFFERS_COMMANDS_H__
void buffers_paste_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void buffers_paste_as_new_image_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void buffers_delete_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __BUFFERS_COMMANDS_H__ */

View File

@ -0,0 +1,349 @@
/* 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/pikaimage.h"
#include "core/pikaitem.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikacomponenteditor.h"
#include "widgets/pikahelp-ids.h"
#include "actions.h"
#include "channels-actions.h"
#include "channels-commands.h"
#include "items-actions.h"
#include "pika-intl.h"
static const PikaActionEntry channels_actions[] =
{
{ "channels-edit-attributes", PIKA_ICON_EDIT,
NC_("channels-action", "_Edit Channel Attributes..."), NULL, { NULL },
NC_("channels-action", "Edit the channel's name, color and opacity"),
channels_edit_attributes_cmd_callback,
PIKA_HELP_CHANNEL_EDIT },
{ "channels-new", PIKA_ICON_DOCUMENT_NEW,
NC_("channels-action", "_New Channel..."), NULL, { NULL },
NC_("channels-action", "Create a new channel"),
channels_new_cmd_callback,
PIKA_HELP_CHANNEL_NEW },
{ "channels-new-last-values", PIKA_ICON_DOCUMENT_NEW,
NC_("channels-action", "_New Channel"), NULL, { NULL },
NC_("channels-action", "Create a new channel with last used values"),
channels_new_last_vals_cmd_callback,
PIKA_HELP_CHANNEL_NEW },
{ "channels-duplicate", PIKA_ICON_OBJECT_DUPLICATE,
NC_("channels-action", "D_uplicate Channels"), NULL, { NULL },
NC_("channels-action",
"Create duplicates of selected channels and add them to the image"),
channels_duplicate_cmd_callback,
PIKA_HELP_CHANNEL_DUPLICATE },
{ "channels-delete", PIKA_ICON_EDIT_DELETE,
NC_("channels-action", "_Delete Channels"), NULL, { NULL },
NC_("channels-action", "Delete selected channels"),
channels_delete_cmd_callback,
PIKA_HELP_CHANNEL_DELETE },
{ "channels-raise", PIKA_ICON_GO_UP,
NC_("channels-action", "_Raise Channels"), NULL, { NULL },
NC_("channels-action", "Raise these channels one step in the channel stack"),
channels_raise_cmd_callback,
PIKA_HELP_CHANNEL_RAISE },
{ "channels-raise-to-top", PIKA_ICON_GO_TOP,
NC_("channels-action", "Raise Channels to _Top"), NULL, { NULL },
NC_("channels-action",
"Raise these channels to the top of the channel stack"),
channels_raise_to_top_cmd_callback,
PIKA_HELP_CHANNEL_RAISE_TO_TOP },
{ "channels-lower", PIKA_ICON_GO_DOWN,
NC_("channels-action", "_Lower Channels"), NULL, { NULL },
NC_("channels-action", "Lower these channels one step in the channel stack"),
channels_lower_cmd_callback,
PIKA_HELP_CHANNEL_LOWER },
{ "channels-lower-to-bottom", PIKA_ICON_GO_BOTTOM,
NC_("channels-action", "Lower Channels to _Bottom"), NULL, { NULL },
NC_("channels-action",
"Lower these channels to the bottom of the channel stack"),
channels_lower_to_bottom_cmd_callback,
PIKA_HELP_CHANNEL_LOWER_TO_BOTTOM }
};
static const PikaToggleActionEntry channels_toggle_actions[] =
{
{ "channels-visible", PIKA_ICON_VISIBLE,
NC_("channels-action", "Toggle Channel _Visibility"), NULL, { NULL }, NULL,
channels_visible_cmd_callback,
FALSE,
PIKA_HELP_CHANNEL_VISIBLE },
{ "channels-lock-content", PIKA_ICON_LOCK_CONTENT,
NC_("channels-action", "L_ock Pixels of Channel"), NULL, { NULL }, NULL,
channels_lock_content_cmd_callback,
FALSE,
PIKA_HELP_CHANNEL_LOCK_PIXELS },
{ "channels-lock-position", PIKA_ICON_LOCK_POSITION,
NC_("channels-action", "L_ock Position of Channel"), NULL, { NULL }, NULL,
channels_lock_position_cmd_callback,
FALSE,
PIKA_HELP_CHANNEL_LOCK_POSITION }
};
static const PikaEnumActionEntry channels_color_tag_actions[] =
{
{ "channels-color-tag-none", PIKA_ICON_EDIT_CLEAR,
NC_("channels-action", "None"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Clear"),
PIKA_COLOR_TAG_NONE, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-blue", NULL,
NC_("channels-action", "Blue"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Blue"),
PIKA_COLOR_TAG_BLUE, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-green", NULL,
NC_("channels-action", "Green"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Green"),
PIKA_COLOR_TAG_GREEN, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-yellow", NULL,
NC_("channels-action", "Yellow"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Yellow"),
PIKA_COLOR_TAG_YELLOW, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-orange", NULL,
NC_("channels-action", "Orange"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Orange"),
PIKA_COLOR_TAG_ORANGE, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-brown", NULL,
NC_("channels-action", "Brown"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Brown"),
PIKA_COLOR_TAG_BROWN, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-red", NULL,
NC_("channels-action", "Red"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Red"),
PIKA_COLOR_TAG_RED, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-violet", NULL,
NC_("channels-action", "Violet"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Violet"),
PIKA_COLOR_TAG_VIOLET, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG },
{ "channels-color-tag-gray", NULL,
NC_("channels-action", "Gray"), NULL, { NULL },
NC_("channels-action", "Channel Color Tag: Set to Gray"),
PIKA_COLOR_TAG_GRAY, FALSE,
PIKA_HELP_CHANNEL_COLOR_TAG }
};
static const PikaEnumActionEntry channels_to_selection_actions[] =
{
{ "channels-selection-replace", PIKA_ICON_SELECTION_REPLACE,
NC_("channels-action", "Channels to Sele_ction"), NULL, { NULL },
NC_("channels-action", "Replace the selection with selected channels"),
PIKA_CHANNEL_OP_REPLACE, FALSE,
PIKA_HELP_CHANNEL_SELECTION_REPLACE },
{ "channels-selection-add", PIKA_ICON_SELECTION_ADD,
NC_("channels-action", "_Add Channels to Selection"), NULL, { NULL },
NC_("channels-action", "Add selected channels to the current selection"),
PIKA_CHANNEL_OP_ADD, FALSE,
PIKA_HELP_CHANNEL_SELECTION_ADD },
{ "channels-selection-subtract", PIKA_ICON_SELECTION_SUBTRACT,
NC_("channels-action", "_Subtract Channels from Selection"), NULL, { NULL },
NC_("channels-action", "Subtract selected channels from the current selection"),
PIKA_CHANNEL_OP_SUBTRACT, FALSE,
PIKA_HELP_CHANNEL_SELECTION_SUBTRACT },
{ "channels-selection-intersect", PIKA_ICON_SELECTION_INTERSECT,
NC_("channels-action", "_Intersect Channels with Selection"), NULL, { NULL },
NC_("channels-action", "Intersect selected channels with the current selection and each other"),
PIKA_CHANNEL_OP_INTERSECT, FALSE,
PIKA_HELP_CHANNEL_SELECTION_INTERSECT }
};
static const PikaEnumActionEntry channels_select_actions[] =
{
{ "channels-select-top", NULL,
NC_("channels-action", "Select _Top Channel"), NULL, { NULL },
NC_("channels-action", "Select the topmost channel"),
PIKA_ACTION_SELECT_FIRST, FALSE,
PIKA_HELP_CHANNEL_TOP },
{ "channels-select-bottom", NULL,
NC_("channels-action", "Select _Bottom Channel"), NULL, { NULL },
NC_("channels-action", "Select the bottommost channel"),
PIKA_ACTION_SELECT_LAST, FALSE,
PIKA_HELP_CHANNEL_BOTTOM },
{ "channels-select-previous", NULL,
NC_("channels-action", "Select _Previous Channels"), NULL, { NULL },
NC_("channels-action", "Select the channels above the selected channels"),
PIKA_ACTION_SELECT_PREVIOUS, FALSE,
PIKA_HELP_CHANNEL_PREVIOUS },
{ "channels-select-next", NULL,
NC_("channels-action", "Select _Next Channels"), NULL, { NULL },
NC_("channels-action", "Select the channels below the selected channels"),
PIKA_ACTION_SELECT_NEXT, FALSE,
PIKA_HELP_CHANNEL_NEXT }
};
void
channels_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_actions (group, "channels-action",
channels_actions,
G_N_ELEMENTS (channels_actions));
pika_action_group_add_toggle_actions (group, "channels-action",
channels_toggle_actions,
G_N_ELEMENTS (channels_toggle_actions));
pika_action_group_add_enum_actions (group, "channels-action",
channels_color_tag_actions,
G_N_ELEMENTS (channels_color_tag_actions),
channels_color_tag_cmd_callback);
pika_action_group_add_enum_actions (group, "channels-action",
channels_to_selection_actions,
G_N_ELEMENTS (channels_to_selection_actions),
channels_to_selection_cmd_callback);
pika_action_group_add_enum_actions (group, "channels-action",
channels_select_actions,
G_N_ELEMENTS (channels_select_actions),
channels_select_cmd_callback);
items_actions_setup (group, "channels");
}
void
channels_actions_update (PikaActionGroup *group,
gpointer data)
{
PikaImage *image = action_data_get_image (data);
gboolean fs = FALSE;
gboolean component = FALSE;
GList *selected_channels = NULL;
gint n_selected_channels = 0;
gint n_channels = 0;
gboolean have_prev = FALSE; /* At least 1 selected channel has a previous sibling. */
gboolean have_next = FALSE; /* At least 1 selected channel has a next sibling. */
if (image)
{
fs = (pika_image_get_floating_selection (image) != NULL);
if (PIKA_IS_COMPONENT_EDITOR (data))
{
if (PIKA_COMPONENT_EDITOR (data)->clicked_component != -1)
component = TRUE;
}
else
{
GList *iter;
selected_channels = pika_image_get_selected_channels (image);
n_selected_channels = g_list_length (selected_channels);
n_channels = pika_image_get_n_channels (image);
for (iter = selected_channels; iter; iter = iter->next)
{
GList *channel_list;
GList *list;
channel_list = pika_item_get_container_iter (PIKA_ITEM (iter->data));
list = g_list_find (channel_list, iter->data);
if (list)
{
if (g_list_previous (list))
have_prev = TRUE;
if (g_list_next (list))
have_next = TRUE;
}
if (have_prev && have_next)
break;
}
}
}
#define SET_SENSITIVE(action,condition) \
pika_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)
SET_SENSITIVE ("channels-edit-attributes", !fs && n_selected_channels == 1);
SET_SENSITIVE ("channels-new", !fs && image);
SET_SENSITIVE ("channels-new-last-values", !fs && image);
SET_SENSITIVE ("channels-duplicate", !fs && (n_selected_channels > 0 || component));
SET_SENSITIVE ("channels-delete", !fs && n_selected_channels > 0);
SET_SENSITIVE ("channels-raise", !fs && n_selected_channels > 0 && have_prev);
SET_SENSITIVE ("channels-raise-to-top", !fs && n_selected_channels > 0 && have_prev);
SET_SENSITIVE ("channels-lower", !fs && n_selected_channels > 0 && have_next);
SET_SENSITIVE ("channels-lower-to-bottom", !fs && n_selected_channels > 0 && have_next);
SET_SENSITIVE ("channels-selection-replace", !fs && (n_selected_channels > 0 || component));
SET_SENSITIVE ("channels-selection-add", !fs && (n_selected_channels > 0 || component));
SET_SENSITIVE ("channels-selection-subtract", !fs && (n_selected_channels > 0 || component));
SET_SENSITIVE ("channels-selection-intersect", !fs && (n_selected_channels > 0 || component));
SET_SENSITIVE ("channels-select-top", !fs && n_channels > 0 && (n_selected_channels == 0 || have_prev));
SET_SENSITIVE ("channels-select-bottom", !fs && n_channels > 0 && (n_selected_channels == 0 || have_next));
SET_SENSITIVE ("channels-select-previous", !fs && n_selected_channels > 0 && have_prev);
SET_SENSITIVE ("channels-select-next", !fs && n_selected_channels > 0 && have_next);
#undef SET_SENSITIVE
items_actions_update (group, "channels", selected_channels);
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __CHANNELS_ACTIONS_H__
#define __CHANNELS_ACTIONS_H__
void channels_actions_setup (PikaActionGroup *group);
void channels_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __CHANNELS_ACTIONS_H__ */

View File

@ -0,0 +1,728 @@
/* 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 <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikabase/pikabase.h"
#include "libpikacolor/pikacolor.h"
#include "libpikawidgets/pikawidgets.h"
#include "actions-types.h"
#include "config/pikadialogconfig.h"
#include "core/pika.h"
#include "core/pikachannel.h"
#include "core/pikachannel-select.h"
#include "core/pikacontainer.h"
#include "core/pikacontext.h"
#include "core/pikadrawable-fill.h"
#include "core/pikaimage.h"
#include "core/pikaimage-undo.h"
#include "widgets/pikaaction.h"
#include "widgets/pikacolorpanel.h"
#include "widgets/pikacomponenteditor.h"
#include "widgets/pikadock.h"
#include "widgets/pikahelp-ids.h"
#include "dialogs/dialogs.h"
#include "dialogs/channel-options-dialog.h"
#include "actions.h"
#include "channels-commands.h"
#include "items-commands.h"
#include "pika-intl.h"
#define RGBA_EPSILON 1e-6
/* local function prototypes */
static void channels_new_callback (GtkWidget *dialog,
PikaImage *image,
PikaChannel *channel,
PikaContext *context,
const gchar *channel_name,
const PikaRGB *channel_color,
gboolean save_selection,
gboolean channel_visible,
PikaColorTag channel_color_tag,
gboolean channel_lock_content,
gboolean channel_lock_position,
gboolean channel_lock_visibility,
gpointer user_data);
static void channels_edit_attributes_callback (GtkWidget *dialog,
PikaImage *image,
PikaChannel *channel,
PikaContext *context,
const gchar *channel_name,
const PikaRGB *channel_color,
gboolean save_selection,
gboolean channel_visible,
PikaColorTag channel_color_tag,
gboolean channel_lock_content,
gboolean channel_lock_position,
gboolean channel_lock_visibility,
gpointer user_data);
/* public functions */
void
channels_edit_attributes_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
PikaChannel *channel;
GList *channels;
GtkWidget *widget;
GtkWidget *dialog;
return_if_no_channels (image, channels, data);
return_if_no_widget (widget, data);
#define EDIT_DIALOG_KEY "pika-channel-edit-attributes-dialog"
if (g_list_length (channels) != 1)
return;
channel = channels->data;
dialog = dialogs_get_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY);
if (! dialog)
{
PikaItem *item = PIKA_ITEM (channel);
dialog = channel_options_dialog_new (image, channel,
action_data_get_context (data),
widget,
_("Channel Attributes"),
"pika-channel-edit",
PIKA_ICON_EDIT,
_("Edit Channel Attributes"),
PIKA_HELP_CHANNEL_EDIT,
_("Edit Channel Color"),
_("_Fill opacity:"),
FALSE,
pika_object_get_name (channel),
&channel->color,
pika_item_get_visible (item),
pika_item_get_color_tag (item),
pika_item_get_lock_content (item),
pika_item_get_lock_position (item),
pika_item_get_lock_visibility (item),
channels_edit_attributes_callback,
NULL);
dialogs_attach_dialog (G_OBJECT (channel), EDIT_DIALOG_KEY, dialog);
}
gtk_window_present (GTK_WINDOW (dialog));
}
void
channels_new_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GtkWidget *widget;
GtkWidget *dialog;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
#define NEW_DIALOG_KEY "pika-channel-new-dialog"
dialog = dialogs_get_dialog (G_OBJECT (image), NEW_DIALOG_KEY);
if (! dialog)
{
PikaDialogConfig *config = PIKA_DIALOG_CONFIG (image->pika->config);
dialog = channel_options_dialog_new (image, NULL,
action_data_get_context (data),
widget,
_("New Channel"),
"pika-channel-new",
PIKA_ICON_CHANNEL,
_("Create a New Channel"),
PIKA_HELP_CHANNEL_NEW,
_("New Channel Color"),
_("_Fill opacity:"),
TRUE,
config->channel_new_name,
&config->channel_new_color,
TRUE,
PIKA_COLOR_TAG_NONE,
FALSE,
FALSE,
FALSE,
channels_new_callback,
NULL);
dialogs_attach_dialog (G_OBJECT (image), NEW_DIALOG_KEY, dialog);
}
gtk_window_present (GTK_WINDOW (dialog));
}
void
channels_new_last_vals_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
PikaChannel *channel;
PikaDialogConfig *config;
return_if_no_image (image, data);
config = PIKA_DIALOG_CONFIG (image->pika->config);
channel = pika_channel_new (image,
pika_image_get_width (image),
pika_image_get_height (image),
config->channel_new_name,
&config->channel_new_color);
pika_drawable_fill (PIKA_DRAWABLE (channel),
action_data_get_context (data),
PIKA_FILL_TRANSPARENT);
pika_image_add_channel (image, channel,
PIKA_IMAGE_ACTIVE_PARENT, -1, TRUE);
pika_image_flush (image);
}
void
channels_raise_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
GList *iter;
GList *raised_channels = NULL;
return_if_no_channels (image, channels, data);
for (iter = channels; iter; iter = iter->next)
{
gint index;
index = pika_item_get_index (iter->data);
if (index > 0)
raised_channels = g_list_prepend (raised_channels, iter->data);
}
pika_image_undo_group_start (image,
PIKA_UNDO_GROUP_ITEM_DISPLACE,
ngettext ("Raise Channel",
"Raise Channels",
g_list_length (raised_channels)));
for (iter = raised_channels; iter; iter = iter->next)
pika_image_raise_item (image, iter->data, NULL);
pika_image_flush (image);
pika_image_undo_group_end (image);
g_list_free (raised_channels);
}
void
channels_raise_to_top_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
GList *iter;
GList *raised_channels = NULL;
return_if_no_channels (image, channels, data);
for (iter = channels; iter; iter = iter->next)
{
gint index;
index = pika_item_get_index (iter->data);
if (index > 0)
raised_channels = g_list_prepend (raised_channels, iter->data);
}
pika_image_undo_group_start (image,
PIKA_UNDO_GROUP_ITEM_DISPLACE,
ngettext ("Raise Channel to Top",
"Raise Channels to Top",
g_list_length (raised_channels)));
for (iter = raised_channels; iter; iter = iter->next)
pika_image_raise_item_to_top (image, iter->data);
pika_image_flush (image);
pika_image_undo_group_end (image);
g_list_free (raised_channels);
}
void
channels_lower_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
GList *iter;
GList *lowered_channels = NULL;
return_if_no_channels (image, channels, data);
for (iter = channels; iter; iter = iter->next)
{
GList *layer_list;
gint index;
layer_list = pika_item_get_container_iter (PIKA_ITEM (iter->data));
index = pika_item_get_index (iter->data);
if (index < g_list_length (layer_list) - 1)
lowered_channels = g_list_prepend (lowered_channels, iter->data);
}
pika_image_undo_group_start (image,
PIKA_UNDO_GROUP_ITEM_DISPLACE,
ngettext ("Lower Channel",
"Lower Channels",
g_list_length (lowered_channels)));
for (iter = lowered_channels; iter; iter = iter->next)
pika_image_lower_item (image, iter->data, NULL);
pika_image_flush (image);
pika_image_undo_group_end (image);
g_list_free (lowered_channels);
}
void
channels_lower_to_bottom_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
GList *iter;
GList *lowered_channels = NULL;
return_if_no_channels (image, channels, data);
for (iter = channels; iter; iter = iter->next)
{
GList *layer_list;
gint index;
layer_list = pika_item_get_container_iter (PIKA_ITEM (iter->data));
index = pika_item_get_index (iter->data);
if (index < g_list_length (layer_list) - 1)
lowered_channels = g_list_prepend (lowered_channels, iter->data);
}
pika_image_undo_group_start (image,
PIKA_UNDO_GROUP_ITEM_DISPLACE,
ngettext ("Lower Channel to Bottom",
"Lower Channels to Bottom",
g_list_length (lowered_channels)));
for (iter = lowered_channels; iter; iter = iter->next)
pika_image_lower_item_to_bottom (image, iter->data);
pika_image_flush (image);
pika_image_undo_group_end (image);
g_list_free (lowered_channels);
}
void
channels_duplicate_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image = NULL;
GList *channels;
PikaChannel *parent = PIKA_IMAGE_ACTIVE_PARENT;
return_if_no_channels (image, channels, data);
if (PIKA_IS_COMPONENT_EDITOR (data))
{
PikaChannelType component;
PikaChannel *new_channel;
const gchar *desc;
gchar *name;
component = PIKA_COMPONENT_EDITOR (data)->clicked_component;
pika_enum_get_value (PIKA_TYPE_CHANNEL_TYPE, component,
NULL, NULL, &desc, NULL);
name = g_strdup_printf (_("%s Channel Copy"), desc);
new_channel = pika_channel_new_from_component (image, component,
name, NULL);
/* copied components are invisible by default so subsequent copies
* of components don't affect each other
*/
pika_item_set_visible (PIKA_ITEM (new_channel), FALSE, FALSE);
pika_image_add_channel (image, new_channel, parent, -1, TRUE);
g_free (name);
}
else
{
GList *new_channels = NULL;
GList *iter;
channels = g_list_copy (channels);
pika_image_undo_group_start (image,
PIKA_UNDO_GROUP_CHANNEL_ADD,
_("Duplicate channels"));
for (iter = channels; iter; iter = iter->next)
{
PikaChannel *new_channel;
new_channel = PIKA_CHANNEL (pika_item_duplicate (PIKA_ITEM (iter->data),
G_TYPE_FROM_INSTANCE (iter->data)));
/* use the actual parent here, not PIKA_IMAGE_ACTIVE_PARENT because
* the latter would add a duplicated group inside itself instead of
* above it
*/
pika_image_add_channel (image, new_channel,
pika_channel_get_parent (iter->data),
pika_item_get_index (iter->data),
TRUE);
new_channels = g_list_prepend (new_channels, new_channel);
}
pika_image_set_selected_channels (image, new_channels);
g_list_free (channels);
g_list_free (new_channels);
pika_image_undo_group_end (image);
}
pika_image_flush (image);
}
void
channels_delete_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
GList *iter;
return_if_no_channels (image, channels, data);
channels = g_list_copy (channels);
if (g_list_length (channels) > 1)
{
gchar *undo_name;
undo_name = g_strdup_printf (C_("undo-type", "Remove %d Channels"),
g_list_length (channels));
pika_image_undo_group_start (image, PIKA_UNDO_GROUP_IMAGE_ITEM_REMOVE,
undo_name);
}
for (iter = channels; iter; iter = iter->next)
pika_image_remove_channel (image, iter->data, TRUE, NULL);
if (g_list_length (channels) > 1)
pika_image_undo_group_end (image);
g_list_free (channels);
pika_image_flush (image);
}
void
channels_to_selection_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaChannelOps op;
PikaImage *image;
op = (PikaChannelOps) g_variant_get_int32 (value);
if (PIKA_IS_COMPONENT_EDITOR (data))
{
PikaChannelType component;
return_if_no_image (image, data);
component = PIKA_COMPONENT_EDITOR (data)->clicked_component;
pika_channel_select_component (pika_image_get_mask (image), component,
op, FALSE, 0.0, 0.0);
}
else
{
GList *channels;
GList *iter;
return_if_no_channels (image, channels, data);
pika_image_undo_group_start (image,
PIKA_UNDO_GROUP_DRAWABLE_MOD,
_("Channels to selection"));
for (iter = channels; iter; iter = iter->next)
{
pika_item_to_selection (iter->data, op, TRUE, FALSE, 0.0, 0.0);
if (op == PIKA_CHANNEL_OP_REPLACE && iter == channels)
op = PIKA_CHANNEL_OP_ADD;
}
pika_image_undo_group_end (image);
}
pika_image_flush (image);
}
void
channels_visible_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
return_if_no_channels (image, channels, data);
items_visible_cmd_callback (action, value, image, channels);
}
void
channels_lock_content_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
return_if_no_channels (image, channels, data);
items_lock_content_cmd_callback (action, value, image, channels);
}
void
channels_lock_position_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
return_if_no_channels (image, channels, data);
items_lock_position_cmd_callback (action, value, image, channels);
}
void
channels_color_tag_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
PikaColorTag color_tag;
return_if_no_channels (image, channels, data);
color_tag = (PikaColorTag) g_variant_get_int32 (value);
items_color_tag_cmd_callback (action, image, channels, color_tag);
}
void
channels_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *image;
GList *channels;
GList *new_channels = NULL;
GList *iter;
PikaActionSelectType select_type;
gboolean run_once;
return_if_no_image (image, data);
select_type = (PikaActionSelectType) g_variant_get_int32 (value);
channels = pika_image_get_selected_channels (image);
run_once = (g_list_length (channels) == 0);
for (iter = channels; iter || run_once; iter = iter ? iter->next : NULL)
{
PikaChannel *new_channel = NULL;
PikaContainer *container;
if (iter)
{
container = pika_item_get_container (PIKA_ITEM (iter->data));
}
else /* run_once */
{
container = pika_image_get_channels (image);
run_once = FALSE;
}
new_channel = (PikaChannel *) action_select_object (select_type,
container,
iter ? iter->data : NULL);
if (new_channel)
new_channels = g_list_prepend (new_channels, new_channel);
}
if (new_channels)
{
pika_image_set_selected_channels (image, new_channels);
pika_image_flush (image);
}
g_list_free (new_channels);
}
/* private functions */
static void
channels_new_callback (GtkWidget *dialog,
PikaImage *image,
PikaChannel *channel,
PikaContext *context,
const gchar *channel_name,
const PikaRGB *channel_color,
gboolean save_selection,
gboolean channel_visible,
PikaColorTag channel_color_tag,
gboolean channel_lock_content,
gboolean channel_lock_position,
gboolean channel_lock_visibility,
gpointer user_data)
{
PikaDialogConfig *config = PIKA_DIALOG_CONFIG (image->pika->config);
g_object_set (config,
"channel-new-name", channel_name,
"channel-new-color", channel_color,
NULL);
if (save_selection)
{
PikaChannel *selection = pika_image_get_mask (image);
channel = PIKA_CHANNEL (pika_item_duplicate (PIKA_ITEM (selection),
PIKA_TYPE_CHANNEL));
pika_object_set_name (PIKA_OBJECT (channel),
config->channel_new_name);
pika_channel_set_color (channel, &config->channel_new_color, FALSE);
}
else
{
channel = pika_channel_new (image,
pika_image_get_width (image),
pika_image_get_height (image),
config->channel_new_name,
&config->channel_new_color);
pika_drawable_fill (PIKA_DRAWABLE (channel), context,
PIKA_FILL_TRANSPARENT);
}
pika_item_set_visible (PIKA_ITEM (channel), channel_visible, FALSE);
pika_item_set_color_tag (PIKA_ITEM (channel), channel_color_tag, FALSE);
pika_item_set_lock_content (PIKA_ITEM (channel), channel_lock_content, FALSE);
pika_item_set_lock_position (PIKA_ITEM (channel), channel_lock_position, FALSE);
pika_item_set_lock_visibility (PIKA_ITEM (channel), channel_lock_visibility, FALSE);
pika_image_add_channel (image, channel,
PIKA_IMAGE_ACTIVE_PARENT, -1, TRUE);
pika_image_flush (image);
gtk_widget_destroy (dialog);
}
static void
channels_edit_attributes_callback (GtkWidget *dialog,
PikaImage *image,
PikaChannel *channel,
PikaContext *context,
const gchar *channel_name,
const PikaRGB *channel_color,
gboolean save_selection,
gboolean channel_visible,
PikaColorTag channel_color_tag,
gboolean channel_lock_content,
gboolean channel_lock_position,
gboolean channel_lock_visibility,
gpointer user_data)
{
PikaItem *item = PIKA_ITEM (channel);
if (strcmp (channel_name, pika_object_get_name (channel)) ||
pika_rgba_distance (channel_color, &channel->color) > RGBA_EPSILON ||
channel_visible != pika_item_get_visible (item) ||
channel_color_tag != pika_item_get_color_tag (item) ||
channel_lock_content != pika_item_get_lock_content (item) ||
channel_lock_position != pika_item_get_lock_position (item) ||
channel_lock_visibility != pika_item_get_lock_visibility (item))
{
pika_image_undo_group_start (image,
PIKA_UNDO_GROUP_ITEM_PROPERTIES,
_("Channel Attributes"));
if (strcmp (channel_name, pika_object_get_name (channel)))
pika_item_rename (PIKA_ITEM (channel), channel_name, NULL);
if (pika_rgba_distance (channel_color, &channel->color) > RGBA_EPSILON)
pika_channel_set_color (channel, channel_color, TRUE);
if (channel_visible != pika_item_get_visible (item))
pika_item_set_visible (item, channel_visible, TRUE);
if (channel_color_tag != pika_item_get_color_tag (item))
pika_item_set_color_tag (item, channel_color_tag, TRUE);
if (channel_lock_content != pika_item_get_lock_content (item))
pika_item_set_lock_content (item, channel_lock_content, TRUE);
if (channel_lock_position != pika_item_get_lock_position (item))
pika_item_set_lock_position (item, channel_lock_position, TRUE);
if (channel_lock_visibility != pika_item_get_lock_visibility (item))
pika_item_set_lock_visibility (item, channel_lock_visibility, TRUE);
pika_image_undo_group_end (image);
pika_image_flush (image);
}
gtk_widget_destroy (dialog);
}

View File

@ -0,0 +1,78 @@
/* 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/>.
*/
#ifndef __CHANNELS_COMMANDS_H__
#define __CHANNELS_COMMANDS_H__
void channels_edit_attributes_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_new_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_new_last_vals_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_raise_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_raise_to_top_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_lower_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_lower_to_bottom_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_duplicate_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_delete_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_to_selection_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_visible_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_lock_content_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_lock_position_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_color_tag_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void channels_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __CHANNELS_COMMANDS_H__ */

View File

@ -0,0 +1,177 @@
/* 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/pikacontext.h"
#include "core/pikadrawable.h"
#include "core/pikaimage.h"
#include "core/pikaimage-colormap.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikahelp-ids.h"
#include "actions.h"
#include "colormap-actions.h"
#include "colormap-commands.h"
#include "pika-intl.h"
static const PikaActionEntry colormap_actions[] =
{
{ "colormap-edit-color", PIKA_ICON_EDIT,
NC_("colormap-action", "_Edit Color..."), NULL, { NULL },
NC_("colormap-action", "Edit this color"),
colormap_edit_color_cmd_callback,
PIKA_HELP_INDEXED_PALETTE_EDIT }
};
static const PikaEnumActionEntry colormap_add_color_actions[] =
{
{ "colormap-add-color-from-fg", PIKA_ICON_LIST_ADD,
NC_("colormap-action", "_Add Color from FG"), NULL, { NULL },
NC_("colormap-action", "Add current foreground color"),
FALSE, FALSE,
PIKA_HELP_INDEXED_PALETTE_ADD },
{ "colormap-add-color-from-bg", PIKA_ICON_LIST_ADD,
NC_("colormap-action", "_Add Color from BG"), NULL, { NULL },
NC_("colormap-action", "Add current background color"),
TRUE, FALSE,
PIKA_HELP_INDEXED_PALETTE_ADD }
};
static const PikaEnumActionEntry colormap_to_selection_actions[] =
{
{ "colormap-selection-replace", PIKA_ICON_SELECTION_REPLACE,
NC_("colormap-action", "_Select this Color"), NULL, { NULL },
NC_("colormap-action", "Select all pixels with this color"),
PIKA_CHANNEL_OP_REPLACE, FALSE,
PIKA_HELP_INDEXED_PALETTE_SELECTION_REPLACE },
{ "colormap-selection-add", PIKA_ICON_SELECTION_ADD,
NC_("colormap-action", "_Add to Selection"), NULL, { NULL },
NC_("colormap-action", "Add all pixels with this color to the current selection"),
PIKA_CHANNEL_OP_ADD, FALSE,
PIKA_HELP_INDEXED_PALETTE_SELECTION_ADD },
{ "colormap-selection-subtract", PIKA_ICON_SELECTION_SUBTRACT,
NC_("colormap-action", "_Subtract from Selection"), NULL, { NULL },
NC_("colormap-action", "Subtract all pixels with this color from the current selection"),
PIKA_CHANNEL_OP_SUBTRACT, FALSE,
PIKA_HELP_INDEXED_PALETTE_SELECTION_SUBTRACT },
{ "colormap-selection-intersect", PIKA_ICON_SELECTION_INTERSECT,
NC_("colormap-action", "_Intersect with Selection"), NULL, { NULL },
NC_("colormap-action", "Intersect all pixels with this color with the current selection"),
PIKA_CHANNEL_OP_INTERSECT, FALSE,
PIKA_HELP_INDEXED_PALETTE_SELECTION_INTERSECT }
};
void
colormap_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_actions (group, "colormap-action",
colormap_actions,
G_N_ELEMENTS (colormap_actions));
pika_action_group_add_enum_actions (group, "colormap-action",
colormap_add_color_actions,
G_N_ELEMENTS (colormap_add_color_actions),
colormap_add_color_cmd_callback);
pika_action_group_add_enum_actions (group, "colormap-action",
colormap_to_selection_actions,
G_N_ELEMENTS (colormap_to_selection_actions),
colormap_to_selection_cmd_callback);
}
void
colormap_actions_update (PikaActionGroup *group,
gpointer data)
{
PikaImage *image = action_data_get_image (data);
PikaContext *context = action_data_get_context (data);
gboolean indexed = FALSE;
gboolean drawable_indexed = FALSE;
gint num_colors = 0;
PikaRGB fg;
PikaRGB bg;
if (image)
{
indexed = (pika_image_get_base_type (image) == PIKA_INDEXED);
if (indexed)
{
GList *drawables = pika_image_get_selected_drawables (image);
num_colors = pika_image_get_colormap_size (image);
if (g_list_length (drawables) == 1)
drawable_indexed = pika_drawable_is_indexed (drawables->data);
g_list_free (drawables);
}
}
if (context)
{
pika_context_get_foreground (context, &fg);
pika_context_get_background (context, &bg);
}
#define SET_SENSITIVE(action,condition) \
pika_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)
#define SET_COLOR(action,color) \
pika_action_group_set_action_color (group, action, color, FALSE);
SET_SENSITIVE ("colormap-edit-color",
indexed && num_colors > 0);
SET_SENSITIVE ("colormap-add-color-from-fg",
indexed && num_colors < 256);
SET_SENSITIVE ("colormap-add-color-from-bg",
indexed && num_colors < 256);
SET_COLOR ("colormap-add-color-from-fg", context ? &fg : NULL);
SET_COLOR ("colormap-add-color-from-bg", context ? &bg : NULL);
SET_SENSITIVE ("colormap-selection-replace",
drawable_indexed && num_colors > 0);
SET_SENSITIVE ("colormap-selection-add",
drawable_indexed && num_colors > 0);
SET_SENSITIVE ("colormap-selection-subtract",
drawable_indexed && num_colors > 0);
SET_SENSITIVE ("colormap-selection-intersect",
drawable_indexed && num_colors > 0);
#undef SET_SENSITIVE
#undef SET_COLOR
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __COLORMAP_ACTIONS_H__
#define __COLORMAP_ACTIONS_H__
void colormap_actions_setup (PikaActionGroup *group);
void colormap_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __COLORMAP_ACTIONS_H__ */

View File

@ -0,0 +1,118 @@
/* 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 "actions-types.h"
#include "core/pikachannel-select.h"
#include "core/pikacontext.h"
#include "core/pikaimage.h"
#include "core/pikaimage-colormap.h"
#include "widgets/pikacolormapeditor.h"
#include "widgets/pikacolormapselection.h"
#include "actions.h"
#include "colormap-commands.h"
/* public functions */
void
colormap_edit_color_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaColormapEditor *editor = PIKA_COLORMAP_EDITOR (data);
pika_colormap_editor_edit_color (editor);
}
void
colormap_add_color_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaContext *context;
PikaImage *image;
gboolean background;
return_if_no_context (context, data);
return_if_no_image (image, data);
background = (gboolean) g_variant_get_int32 (value);
if (pika_image_get_colormap_size (image) < 256)
{
PikaRGB color;
if (background)
pika_context_get_background (context, &color);
else
pika_context_get_foreground (context, &color);
pika_image_add_colormap_entry (image, &color);
pika_image_flush (image);
}
}
void
colormap_to_selection_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaColormapSelection *selection;
PikaColormapEditor *editor;
PikaImage *image;
GList *drawables;
PikaChannelOps op;
gint col_index;
return_if_no_image (image, data);
editor = PIKA_COLORMAP_EDITOR (data);
selection = PIKA_COLORMAP_SELECTION (editor->selection);
col_index = pika_colormap_selection_get_index (selection, NULL);
op = (PikaChannelOps) g_variant_get_int32 (value);
drawables = pika_image_get_selected_drawables (image);
if (g_list_length (drawables) != 1)
{
/* We should not reach this anyway as colormap-actions.c normally takes
* care at making the action insensitive when the item selection is wrong.
*/
g_warning ("This action requires exactly one selected drawable.");
g_list_free (drawables);
return;
}
pika_channel_select_by_index (pika_image_get_mask (image),
drawables->data,
col_index, op,
FALSE, 0.0, 0.0);
g_list_free (drawables);
pika_image_flush (image);
}

View File

@ -0,0 +1,37 @@
/* 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/>.
*/
#ifndef __COLORMAP_COMMANDS_H__
#define __COLORMAP_COMMANDS_H__
void colormap_edit_color_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void colormap_add_color_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void colormap_to_selection_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __COLORMAP_COMMANDS_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __CONTEXT_ACTIONS_H__
#define __CONTEXT_ACTIONS_H__
void context_actions_setup (PikaActionGroup *group);
void context_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __CONTEXT_ACTIONS_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,148 @@
/* 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/>.
*/
#ifndef __CONTEXT_COMMANDS_H__
#define __CONTEXT_COMMANDS_H__
void context_colors_default_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_colors_swap_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_palette_foreground_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_palette_background_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_colormap_foreground_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_colormap_background_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_swatch_foreground_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_swatch_background_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_foreground_red_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_foreground_green_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_foreground_blue_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_background_red_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_background_green_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_background_blue_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_foreground_hue_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_foreground_saturation_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_foreground_value_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_background_hue_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_background_saturation_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_background_value_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_opacity_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_paint_mode_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_tool_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_pattern_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_palette_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_gradient_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_font_select_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_spacing_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_shape_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_radius_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_spikes_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_hardness_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_aspect_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_brush_angle_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void context_toggle_dynamics_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __CONTEXT_COMMANDS_H__ */

View File

@ -0,0 +1,74 @@
/* 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 "widgets/pikaactiongroup.h"
#include "widgets/pikahelp-ids.h"
#include "display/pikacursorview.h"
#include "cursor-info-actions.h"
#include "cursor-info-commands.h"
#include "pika-intl.h"
static const PikaToggleActionEntry cursor_info_toggle_actions[] =
{
{ "cursor-info-sample-merged", NULL,
NC_("cursor-info-action", "_Sample Merged"), NULL, { NULL },
NC_("cursor-info-action", "Use the composite color of all visible layers"),
cursor_info_sample_merged_cmd_callback,
TRUE,
PIKA_HELP_POINTER_INFO_SAMPLE_MERGED }
};
void
cursor_info_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_toggle_actions (group, "cursor-info-action",
cursor_info_toggle_actions,
G_N_ELEMENTS (cursor_info_toggle_actions));
}
void
cursor_info_actions_update (PikaActionGroup *group,
gpointer data)
{
PikaCursorView *view = PIKA_CURSOR_VIEW (data);
#define SET_ACTIVE(action,condition) \
pika_action_group_set_action_active (group, action, (condition) != 0)
SET_ACTIVE ("cursor-info-sample-merged",
pika_cursor_view_get_sample_merged (view));
#undef SET_ACTIVE
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __CURSOR_INFO_ACIONS_H__
#define __CURSOR_INFO_ACIONS_H__
void cursor_info_actions_setup (PikaActionGroup *group);
void cursor_info_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __CURSOR_INFO_ACTIONS_H__ */

View File

@ -0,0 +1,45 @@
/* 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 "actions-types.h"
#include "display/pikacursorview.h"
#include "cursor-info-commands.h"
/* public functions */
void
cursor_info_sample_merged_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaCursorView *view = PIKA_CURSOR_VIEW (data);
gboolean active = g_variant_get_boolean (value);
pika_cursor_view_set_sample_merged (view, active);
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __CURSOR_INFO_COMMANDS_H__
#define __CURSOR_INFO_COMMANDS_H__
void cursor_info_sample_merged_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __CURSOR_INFO_COMMANDS_H__ */

View File

@ -0,0 +1,230 @@
/* 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 "widgets/pikaactiongroup.h"
#include "widgets/pikadashboard.h"
#include "widgets/pikahelp-ids.h"
#include "dashboard-actions.h"
#include "dashboard-commands.h"
#include "pika-intl.h"
static const PikaActionEntry dashboard_actions[] =
{
{ "dashboard-groups", NULL,
NC_("dashboard-action", "_Groups") },
{ "dashboard-update-interval", NULL,
NC_("dashboard-action", "_Update Interval") },
{ "dashboard-history-duration", NULL,
NC_("dashboard-action", "_History Duration") },
{ "dashboard-log-record", PIKA_ICON_RECORD,
NC_("dashboard-action", "_Start/Stop Recording..."), NULL, { NULL },
NC_("dashboard-action", "Start/stop recording performance log"),
dashboard_log_record_cmd_callback,
PIKA_HELP_DASHBOARD_LOG_RECORD },
{ "dashboard-log-add-marker", PIKA_ICON_MARKER,
NC_("dashboard-action", "_Add Marker..."), NULL, { NULL },
NC_("dashboard-action", "Add an event marker "
"to the performance log"),
dashboard_log_add_marker_cmd_callback,
PIKA_HELP_DASHBOARD_LOG_ADD_MARKER },
{ "dashboard-log-add-empty-marker", PIKA_ICON_MARKER,
NC_("dashboard-action", "Add _Empty Marker"), NULL, { NULL },
NC_("dashboard-action", "Add an empty event marker "
"to the performance log"),
dashboard_log_add_empty_marker_cmd_callback,
PIKA_HELP_DASHBOARD_LOG_ADD_EMPTY_MARKER },
{ "dashboard-reset", PIKA_ICON_RESET,
NC_("dashboard-action", "_Reset"), NULL, { NULL },
NC_("dashboard-action", "Reset cumulative data"),
dashboard_reset_cmd_callback,
PIKA_HELP_DASHBOARD_RESET },
};
static const PikaToggleActionEntry dashboard_toggle_actions[] =
{
{ "dashboard-low-swap-space-warning", NULL,
NC_("dashboard-action", "_Low Swap Space Warning"), NULL, { NULL },
NC_("dashboard-action", "Raise the dashboard when "
"the swap size approaches its limit"),
dashboard_low_swap_space_warning_cmd_callback,
FALSE,
PIKA_HELP_DASHBOARD_LOW_SWAP_SPACE_WARNING }
};
static const PikaRadioActionEntry dashboard_update_interval_actions[] =
{
{ "dashboard-update-interval-0-25-sec", NULL,
NC_("dashboard-update-interval", "0.25 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_UPDATE_INTERVAL_0_25_SEC,
PIKA_HELP_DASHBOARD_UPDATE_INTERVAL },
{ "dashboard-update-interval-0-5-sec", NULL,
NC_("dashboard-update-interval", "0.5 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_UPDATE_INTERVAL_0_5_SEC,
PIKA_HELP_DASHBOARD_UPDATE_INTERVAL },
{ "dashboard-update-interval-1-sec", NULL,
NC_("dashboard-update-interval", "1 Second"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_UPDATE_INTERVAL_1_SEC,
PIKA_HELP_DASHBOARD_UPDATE_INTERVAL },
{ "dashboard-update-interval-2-sec", NULL,
NC_("dashboard-update-interval", "2 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_UPDATE_INTERVAL_2_SEC,
PIKA_HELP_DASHBOARD_UPDATE_INTERVAL },
{ "dashboard-update-interval-4-sec", NULL,
NC_("dashboard-update-interval", "4 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_UPDATE_INTERVAL_4_SEC,
PIKA_HELP_DASHBOARD_UPDATE_INTERVAL }
};
static const PikaRadioActionEntry dashboard_history_duration_actions[] =
{
{ "dashboard-history-duration-15-sec", NULL,
NC_("dashboard-history-duration", "15 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_HISTORY_DURATION_15_SEC,
PIKA_HELP_DASHBOARD_HISTORY_DURATION },
{ "dashboard-history-duration-30-sec", NULL,
NC_("dashboard-history-duration", "30 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_HISTORY_DURATION_30_SEC,
PIKA_HELP_DASHBOARD_HISTORY_DURATION },
{ "dashboard-history-duration-60-sec", NULL,
NC_("dashboard-history-duration", "60 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_HISTORY_DURATION_60_SEC,
PIKA_HELP_DASHBOARD_HISTORY_DURATION },
{ "dashboard-history-duration-120-sec", NULL,
NC_("dashboard-history-duration", "120 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_HISTORY_DURATION_120_SEC,
PIKA_HELP_DASHBOARD_HISTORY_DURATION },
{ "dashboard-history-duration-240-sec", NULL,
NC_("dashboard-history-duration", "240 Seconds"), NULL, { NULL }, NULL,
PIKA_DASHBOARD_HISTORY_DURATION_240_SEC,
PIKA_HELP_DASHBOARD_HISTORY_DURATION }
};
void
dashboard_actions_setup (PikaActionGroup *group)
{
pika_action_group_add_actions (group, "dashboard-action",
dashboard_actions,
G_N_ELEMENTS (dashboard_actions));
pika_action_group_add_toggle_actions (group, "dashboard-action",
dashboard_toggle_actions,
G_N_ELEMENTS (dashboard_toggle_actions));
pika_action_group_add_radio_actions (group, "dashboard-update-interval",
dashboard_update_interval_actions,
G_N_ELEMENTS (dashboard_update_interval_actions),
NULL,
0,
dashboard_update_interval_cmd_callback);
pika_action_group_add_radio_actions (group, "dashboard-history-duration",
dashboard_history_duration_actions,
G_N_ELEMENTS (dashboard_history_duration_actions),
NULL,
0,
dashboard_history_duration_cmd_callback);
}
void
dashboard_actions_update (PikaActionGroup *group,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
gboolean recording;
recording = pika_dashboard_log_is_recording (dashboard);
#define SET_SENSITIVE(action,condition) \
pika_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)
#define SET_ACTIVE(action,condition) \
pika_action_group_set_action_active (group, action, (condition) != 0)
switch (pika_dashboard_get_update_interval (dashboard))
{
case PIKA_DASHBOARD_UPDATE_INTERVAL_0_25_SEC:
SET_ACTIVE ("dashboard-update-interval-0-25-sec", TRUE);
break;
case PIKA_DASHBOARD_UPDATE_INTERVAL_0_5_SEC:
SET_ACTIVE ("dashboard-update-interval-0-5-sec", TRUE);
break;
case PIKA_DASHBOARD_UPDATE_INTERVAL_1_SEC:
SET_ACTIVE ("dashboard-update-interval-1-sec", TRUE);
break;
case PIKA_DASHBOARD_UPDATE_INTERVAL_2_SEC:
SET_ACTIVE ("dashboard-update-interval-2-sec", TRUE);
break;
case PIKA_DASHBOARD_UPDATE_INTERVAL_4_SEC:
SET_ACTIVE ("dashboard-update-interval-4-sec", TRUE);
break;
}
switch (pika_dashboard_get_history_duration (dashboard))
{
case PIKA_DASHBOARD_HISTORY_DURATION_15_SEC:
SET_ACTIVE ("dashboard-history-duration-15-sec", TRUE);
break;
case PIKA_DASHBOARD_HISTORY_DURATION_30_SEC:
SET_ACTIVE ("dashboard-history-duration-30-sec", TRUE);
break;
case PIKA_DASHBOARD_HISTORY_DURATION_60_SEC:
SET_ACTIVE ("dashboard-history-duration-60-sec", TRUE);
break;
case PIKA_DASHBOARD_HISTORY_DURATION_120_SEC:
SET_ACTIVE ("dashboard-history-duration-120-sec", TRUE);
break;
case PIKA_DASHBOARD_HISTORY_DURATION_240_SEC:
SET_ACTIVE ("dashboard-history-duration-240-sec", TRUE);
break;
}
SET_SENSITIVE ("dashboard-log-add-marker", recording);
SET_SENSITIVE ("dashboard-log-add-empty-marker", recording);
SET_SENSITIVE ("dashboard-reset", !recording);
SET_ACTIVE ("dashboard-low-swap-space-warning",
pika_dashboard_get_low_swap_space_warning (dashboard));
#undef SET_SENSITIVE
#undef SET_ACTIVE
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __DASHBOARD_ACTIONS_H__
#define __DASHBOARD_ACTIONS_H__
void dashboard_actions_setup (PikaActionGroup *group);
void dashboard_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __DASHBOARD_ACTIONS_H__ */

View File

@ -0,0 +1,410 @@
/* 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/pikadashboard.h"
#include "widgets/pikahelp-ids.h"
#include "widgets/pikauimanager.h"
#include "dialogs/dialogs.h"
#include "dashboard-commands.h"
#include "pika-intl.h"
typedef struct
{
GFile *folder;
PikaDashboardLogParams params;
} DashboardLogDialogInfo;
/* local function prototypes */
static void dashboard_log_record_response (GtkWidget *dialog,
int response_id,
PikaDashboard *dashboard);
static void dashboard_log_add_marker_response (GtkWidget *dialog,
const gchar *description,
PikaDashboard *dashboard);
static DashboardLogDialogInfo * dashboard_log_dialog_info_new (PikaDashboard *dashboard);
static void dashboard_log_dialog_info_free (DashboardLogDialogInfo *info);
/* public functions */
void
dashboard_update_interval_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
PikaDashboardUpdateInteval update_interval;
update_interval = g_variant_get_int32 (value);
pika_dashboard_set_update_interval (dashboard, update_interval);
}
void
dashboard_history_duration_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
PikaDashboardHistoryDuration history_duration;
history_duration = g_variant_get_int32 (value);
pika_dashboard_set_history_duration (dashboard, history_duration);
}
void
dashboard_log_record_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
if (! pika_dashboard_log_is_recording (dashboard))
{
GtkWidget *dialog;
#define LOG_RECORD_KEY "pika-dashboard-log-record-dialog"
dialog = dialogs_get_dialog (G_OBJECT (dashboard), LOG_RECORD_KEY);
if (! dialog)
{
GtkFileFilter *filter;
DashboardLogDialogInfo *info;
GtkWidget *hbox;
GtkWidget *hbox2;
GtkWidget *label;
GtkWidget *spinbutton;
GtkWidget *toggle;
dialog = gtk_file_chooser_dialog_new (
"Record Performance Log", NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Record"), GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog),
GTK_RESPONSE_OK);
pika_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gtk_window_set_screen (
GTK_WINDOW (dialog),
gtk_widget_get_screen (GTK_WIDGET (dashboard)));
gtk_window_set_role (GTK_WINDOW (dialog),
"pika-dashboard-log-record");
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
gtk_file_chooser_set_do_overwrite_confirmation (
GTK_FILE_CHOOSER (dialog), TRUE);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All Files"));
gtk_file_filter_add_pattern (filter, "*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Log Files (*.log)"));
gtk_file_filter_add_pattern (filter, "*.log");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
info = g_object_get_data (G_OBJECT (dashboard),
"pika-dashboard-log-dialog-info");
if (! info)
{
info = dashboard_log_dialog_info_new (dashboard);
g_object_set_data_full (
G_OBJECT (dashboard),
"pika-dashboard-log-dialog-info", info,
(GDestroyNotify) dashboard_log_dialog_info_free);
}
if (info->folder)
{
gtk_file_chooser_set_current_folder_file (
GTK_FILE_CHOOSER (dialog), info->folder, NULL);
}
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog),
"pika-performance.log");
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox);
gtk_widget_show (hbox);
hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
pika_help_set_help_data (hbox2, _("Log samples per second"), NULL);
gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
gtk_widget_show (hbox2);
label = gtk_label_new_with_mnemonic (_("Sample fre_quency:"));
gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
gtk_widget_show (label);
spinbutton = pika_spin_button_new_with_range (1, 1000, 1);
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton),
info->params.sample_frequency);
g_signal_connect (gtk_spin_button_get_adjustment (
GTK_SPIN_BUTTON (spinbutton)),
"value-changed",
G_CALLBACK (pika_int_adjustment_update),
&info->params.sample_frequency);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinbutton);
toggle = gtk_check_button_new_with_mnemonic (_("_Backtrace"));
pika_help_set_help_data (toggle, _("Include backtraces in log"),
NULL);
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
info->params.backtrace);
g_signal_connect (toggle, "toggled",
G_CALLBACK (pika_toggle_button_update),
&info->params.backtrace);
toggle = gtk_check_button_new_with_mnemonic (_("_Messages"));
pika_help_set_help_data (toggle,
_("Include diagnostic messages in log"),
NULL);
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
info->params.messages);
g_signal_connect (toggle, "toggled",
G_CALLBACK (pika_toggle_button_update),
&info->params.messages);
toggle = gtk_check_button_new_with_mnemonic (_("Progressi_ve"));
pika_help_set_help_data (toggle,
_("Produce complete log "
"even if not properly terminated"),
NULL);
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
gtk_widget_show (toggle);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
info->params.progressive);
g_signal_connect (toggle, "toggled",
G_CALLBACK (pika_toggle_button_update),
&info->params.progressive);
g_signal_connect (dialog, "response",
G_CALLBACK (dashboard_log_record_response),
dashboard);
g_signal_connect (dialog, "delete-event",
G_CALLBACK (gtk_true),
NULL);
pika_help_connect (dialog, pika_standard_help_func,
PIKA_HELP_DASHBOARD_LOG_RECORD, NULL, NULL);
dialogs_attach_dialog (G_OBJECT (dashboard), LOG_RECORD_KEY, dialog);
g_signal_connect_object (dashboard, "destroy",
G_CALLBACK (gtk_widget_destroy),
dialog,
G_CONNECT_SWAPPED);
#undef LOG_RECORD_KEY
}
gtk_window_present (GTK_WINDOW (dialog));
}
else
{
GError *error = NULL;
if (! pika_dashboard_log_stop_recording (dashboard, &error))
{
pika_message_literal (
pika_editor_get_ui_manager (PIKA_EDITOR (dashboard))->pika,
NULL, PIKA_MESSAGE_ERROR, error->message);
}
}
}
void
dashboard_log_add_marker_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
GtkWidget *dialog;
#define LOG_ADD_MARKER_KEY "pika-dashboard-log-add-marker-dialog"
dialog = dialogs_get_dialog (G_OBJECT (dashboard), LOG_ADD_MARKER_KEY);
if (! dialog)
{
dialog = pika_query_string_box (
_("Add Marker"), GTK_WIDGET (dashboard),
pika_standard_help_func, PIKA_HELP_DASHBOARD_LOG_ADD_MARKER,
_("Enter a description for the marker"),
NULL,
G_OBJECT (dashboard), "destroy",
(PikaQueryStringCallback) dashboard_log_add_marker_response,
dashboard, NULL);
dialogs_attach_dialog (G_OBJECT (dashboard), LOG_ADD_MARKER_KEY, dialog);
#undef LOG_ADD_MARKER_KEY
}
gtk_window_present (GTK_WINDOW (dialog));
}
void
dashboard_log_add_empty_marker_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
pika_dashboard_log_add_marker (dashboard, NULL);
}
void
dashboard_reset_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
pika_dashboard_reset (dashboard);
}
void
dashboard_low_swap_space_warning_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDashboard *dashboard = PIKA_DASHBOARD (data);
gboolean low_swap_space_warning = g_variant_get_boolean (value);
pika_dashboard_set_low_swap_space_warning (dashboard, low_swap_space_warning);
}
/* private functions */
static void
dashboard_log_record_response (GtkWidget *dialog,
int response_id,
PikaDashboard *dashboard)
{
if (response_id == GTK_RESPONSE_OK)
{
GFile *file;
DashboardLogDialogInfo *info;
GError *error = NULL;
file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
info = g_object_get_data (G_OBJECT (dashboard),
"pika-dashboard-log-dialog-info");
g_return_if_fail (info != NULL);
g_set_object (&info->folder, g_file_get_parent (file));
if (! pika_dashboard_log_start_recording (dashboard,
file, &info->params,
&error))
{
pika_message_literal (
pika_editor_get_ui_manager (PIKA_EDITOR (dashboard))->pika,
NULL, PIKA_MESSAGE_ERROR, error->message);
g_clear_error (&error);
}
g_object_unref (file);
}
gtk_widget_destroy (dialog);
}
static void
dashboard_log_add_marker_response (GtkWidget *dialog,
const gchar *description,
PikaDashboard *dashboard)
{
pika_dashboard_log_add_marker (dashboard, description);
}
static DashboardLogDialogInfo *
dashboard_log_dialog_info_new (PikaDashboard *dashboard)
{
DashboardLogDialogInfo *info = g_slice_new (DashboardLogDialogInfo);
info->folder = NULL;
info->params = *pika_dashboard_log_get_default_params (dashboard);
return info;
}
static void
dashboard_log_dialog_info_free (DashboardLogDialogInfo *info)
{
g_clear_object (&info->folder);
g_slice_free (DashboardLogDialogInfo, info);
}

View File

@ -0,0 +1,52 @@
/* 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/>.
*/
#ifndef __DASHBOARD_COMMANDS_H__
#define __DASHBOARD_COMMANDS_H__
void dashboard_update_interval_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void dashboard_history_duration_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void dashboard_log_record_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void dashboard_log_add_marker_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void dashboard_log_add_empty_marker_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void dashboard_reset_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void dashboard_low_swap_space_warning_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __DASHBOARD_COMMANDS_H__ */

305
app/actions/data-commands.c Normal file
View File

@ -0,0 +1,305 @@
/* 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 "libpikabase/pikabase.h"
#include "libpikawidgets/pikawidgets.h"
#include "actions-types.h"
#include "core/pika.h"
#include "core/pikacontainer.h"
#include "core/pikacontext.h"
#include "core/pikadata.h"
#include "core/pikadatafactory.h"
#include "file/file-open.h"
#include "widgets/pikaclipboard.h"
#include "widgets/pikacontainerview.h"
#include "widgets/pikadataeditor.h"
#include "widgets/pikadatafactoryview.h"
#include "widgets/pikadialogfactory.h"
#include "widgets/pikamessagebox.h"
#include "widgets/pikamessagedialog.h"
#include "widgets/pikawidgets-utils.h"
#include "widgets/pikawindowstrategy.h"
#include "widgets/pikawidgets-utils.h"
#include "dialogs/data-delete-dialog.h"
#include "actions.h"
#include "data-commands.h"
#include "pika-intl.h"
/* public functions */
void
data_open_as_image_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
PikaContext *context;
PikaData *data;
context =
pika_container_view_get_context (PIKA_CONTAINER_EDITOR (view)->view);
data = (PikaData *)
pika_context_get_by_type (context,
pika_data_factory_view_get_children_type (view));
if (data && pika_data_get_file (data))
{
GFile *file = pika_data_get_file (data);
GtkWidget *widget = GTK_WIDGET (view);
PikaImage *image;
PikaPDBStatusType status;
GError *error = NULL;
image = file_open_with_display (context->pika, context, NULL,
file, FALSE,
G_OBJECT (pika_widget_get_monitor (widget)),
&status, &error);
if (! image && status != PIKA_PDB_CANCEL)
{
pika_message (context->pika, G_OBJECT (view),
PIKA_MESSAGE_ERROR,
_("Opening '%s' failed:\n\n%s"),
pika_file_get_utf8_name (file), error->message);
g_clear_error (&error);
}
}
}
void
data_new_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
if (pika_data_factory_view_has_data_new_func (view))
{
PikaDataFactory *factory;
PikaContext *context;
PikaData *data;
factory = pika_data_factory_view_get_data_factory (view);
context =
pika_container_view_get_context (PIKA_CONTAINER_EDITOR (view)->view);
data = pika_data_factory_data_new (factory, context, _("Untitled"));
if (data)
{
pika_context_set_by_type (context,
pika_data_factory_view_get_children_type (view),
PIKA_OBJECT (data));
gtk_button_clicked (GTK_BUTTON (pika_data_factory_view_get_edit_button (view)));
}
}
}
void
data_duplicate_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
PikaContext *context;
PikaData *data;
context = pika_container_view_get_context (PIKA_CONTAINER_EDITOR (view)->view);
data = (PikaData *)
pika_context_get_by_type (context,
pika_data_factory_view_get_children_type (view));
if (data && pika_data_factory_view_have (view, PIKA_OBJECT (data)))
{
PikaData *new_data;
new_data = pika_data_factory_data_duplicate (pika_data_factory_view_get_data_factory (view), data);
if (new_data)
{
pika_context_set_by_type (context,
pika_data_factory_view_get_children_type (view),
PIKA_OBJECT (new_data));
gtk_button_clicked (GTK_BUTTON (pika_data_factory_view_get_edit_button (view)));
}
}
}
void
data_copy_location_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
PikaContext *context;
PikaData *data;
context = pika_container_view_get_context (PIKA_CONTAINER_EDITOR (view)->view);
data = (PikaData *)
pika_context_get_by_type (context,
pika_data_factory_view_get_children_type (view));
if (data)
{
GFile *file = pika_data_get_file (data);
if (file)
{
gchar *uri = g_file_get_uri (file);
pika_clipboard_set_text (context->pika, uri);
g_free (uri);
}
}
}
void
data_show_in_file_manager_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
PikaContext *context;
PikaData *data;
context = pika_container_view_get_context (PIKA_CONTAINER_EDITOR (view)->view);
data = (PikaData *)
pika_context_get_by_type (context,
pika_data_factory_view_get_children_type (view));
if (data)
{
GFile *file = pika_data_get_file (data);
if (file)
{
GError *error = NULL;
if (! pika_file_show_in_file_manager (file, &error))
{
pika_message (context->pika, G_OBJECT (view),
PIKA_MESSAGE_ERROR,
_("Can't show file in file manager: %s"),
error->message);
g_clear_error (&error);
}
}
}
}
void
data_delete_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
PikaContext *context;
PikaData *data;
context =
pika_container_view_get_context (PIKA_CONTAINER_EDITOR (view)->view);
data = (PikaData *)
pika_context_get_by_type (context,
pika_data_factory_view_get_children_type (view));
if (data &&
pika_data_is_deletable (data) &&
pika_data_factory_view_have (view, PIKA_OBJECT (data)))
{
PikaDataFactory *factory;
GtkWidget *dialog;
factory = pika_data_factory_view_get_data_factory (view);
dialog = data_delete_dialog_new (factory, data, context,
GTK_WIDGET (view));
gtk_widget_show (dialog);
}
}
void
data_refresh_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
Pika *pika;
return_if_no_pika (pika, user_data);
pika_set_busy (pika);
pika_data_factory_data_refresh (pika_data_factory_view_get_data_factory (view),
action_data_get_context (user_data));
pika_unset_busy (pika);
}
void
data_edit_cmd_callback (PikaAction *action,
GVariant *value,
gpointer user_data)
{
PikaDataFactoryView *view = PIKA_DATA_FACTORY_VIEW (user_data);
PikaContext *context;
PikaData *data;
context = pika_container_view_get_context (PIKA_CONTAINER_EDITOR (view)->view);
data = (PikaData *)
pika_context_get_by_type (context,
pika_data_factory_view_get_children_type (view));
if (data && pika_data_factory_view_have (view, PIKA_OBJECT (data)))
{
GdkMonitor *monitor = pika_widget_get_monitor (GTK_WIDGET (view));
GtkWidget *dockable;
dockable =
pika_window_strategy_show_dockable_dialog (PIKA_WINDOW_STRATEGY (pika_get_window_strategy (context->pika)),
context->pika,
pika_dialog_factory_get_singleton (),
monitor,
g_variant_get_string (value,
NULL));
pika_data_editor_set_data (PIKA_DATA_EDITOR (gtk_bin_get_child (GTK_BIN (dockable))),
data);
}
}

View File

@ -0,0 +1,52 @@
/* 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/>.
*/
#ifndef __DATA_COMMANDS_H__
#define __DATA_COMMANDS_H__
void data_open_as_image_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void data_new_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void data_duplicate_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void data_copy_location_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void data_show_in_file_manager_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void data_delete_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void data_refresh_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void data_edit_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __DATA_COMMANDS_H__ */

View File

@ -0,0 +1,47 @@
/* 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 "actions-types.h"
#include "widgets/pikadataeditor.h"
#include "data-editor-commands.h"
/* public functions */
void
data_editor_edit_active_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDataEditor *editor = PIKA_DATA_EDITOR (data);
gboolean edit_active;
edit_active = g_variant_get_boolean (value);
pika_data_editor_set_edit_active (editor, edit_active);
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __DATA_EDITOR_COMMANDS_H__
#define __DATA_EDITOR_COMMANDS_H__
void data_editor_edit_active_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __DATA_EDITOR_COMMANDS_H__ */

106
app/actions/debug-actions.c Normal file
View File

@ -0,0 +1,106 @@
/* 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 "debug-actions.h"
#include "debug-commands.h"
#include "pika-intl.h"
static const PikaActionEntry debug_actions[] =
{
{ "debug-gtk-inspector", NULL,
N_("Start _GtkInspector"), NULL, { NULL }, NULL,
debug_gtk_inspector_cmd_callback,
NULL },
{ "debug-mem-profile", NULL,
N_("_Memory Profile"), NULL, { NULL }, NULL,
debug_mem_profile_cmd_callback,
NULL },
{ "debug-benchmark-projection", NULL,
N_("Benchmark _Projection"), NULL, { NULL },
N_("Invalidates the entire projection, measures the time it takes to "
"validate (render) the part that is visible in the active display, "
"and print the result to stdout."),
debug_benchmark_projection_cmd_callback,
NULL },
{ "debug-show-image-graph", NULL,
N_("Show Image _Graph"), NULL, { NULL },
N_("Creates a new image showing the GEGL graph of this image"),
debug_show_image_graph_cmd_callback,
NULL },
{ "debug-dump-keyboard-shortcuts", NULL,
N_("Dump _Keyboard Shortcuts"), NULL, { NULL }, NULL,
debug_dump_keyboard_shortcuts_cmd_callback,
NULL },
{ "debug-dump-attached-data", NULL,
N_("Dump _Attached Data"), NULL, { NULL }, NULL,
debug_dump_attached_data_cmd_callback,
NULL }
};
void
debug_actions_setup (PikaActionGroup *group)
{
gint i;
pika_action_group_add_actions (group, NULL,
debug_actions,
G_N_ELEMENTS (debug_actions));
#define SET_VISIBLE(action,condition) \
pika_action_group_set_action_visible (group, action, (condition) != 0)
for (i = 0; i < G_N_ELEMENTS (debug_actions); i++)
SET_VISIBLE (debug_actions[i].name, group->pika->show_debug_menu);
#undef SET_VISIBLE
}
void
debug_actions_update (PikaActionGroup *group,
gpointer data)
{
#define SET_SENSITIVE(action,condition) \
pika_action_group_set_action_sensitive (group, action, (condition) != 0, NULL)
SET_SENSITIVE ("debug-show-image-graph", gegl_has_operation ("gegl:introspect"));
#undef SET_SENSITIVE
}

View File

@ -0,0 +1,31 @@
/* 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/>.
*/
#ifndef __DEBUG_ACTIONS_H__
#define __DEBUG_ACTIONS_H__
void debug_actions_setup (PikaActionGroup *group);
void debug_actions_update (PikaActionGroup *group,
gpointer data);
#endif /* __DEBUG_ACTIONS_H__ */

View File

@ -0,0 +1,302 @@
/* 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 <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libpikabase/pikabase.h"
#include "actions-types.h"
#include "core/pika.h"
#include "core/pika-utils.h"
#include "core/pikacontext.h"
#include "core/pikaimage.h"
#include "core/pikaprojectable.h"
#include "core/pikaprojection.h"
#include "gegl/pika-gegl-utils.h"
#include "widgets/pikaaction.h"
#include "widgets/pikaactiongroup.h"
#include "widgets/pikamenufactory.h"
#include "widgets/pikauimanager.h"
#include "display/pikadisplay.h"
#include "display/pikadisplayshell.h"
#include "display/pikaimagewindow.h"
#include "menus/menus.h"
#include "actions.h"
#include "debug-commands.h"
/* local function prototypes */
static gboolean debug_benchmark_projection (PikaDisplay *display);
static gboolean debug_show_image_graph (PikaImage *source_image);
static void debug_print_qdata (PikaObject *object);
static void debug_print_qdata_foreach (GQuark key_id,
gpointer data,
gpointer user_data);
/* public functions */
void
debug_gtk_inspector_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
gtk_window_set_interactive_debugging (TRUE);
}
void
debug_mem_profile_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
extern gboolean pika_debug_memsize;
Pika *pika;
return_if_no_pika (pika, data);
pika_debug_memsize = TRUE;
pika_object_get_memsize (PIKA_OBJECT (pika), NULL);
pika_debug_memsize = FALSE;
}
void
debug_benchmark_projection_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDisplay *display;
return_if_no_display (display, data);
g_idle_add ((GSourceFunc) debug_benchmark_projection, g_object_ref (display));
}
void
debug_show_image_graph_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaImage *source_image = NULL;
return_if_no_image (source_image, data);
g_idle_add ((GSourceFunc) debug_show_image_graph, g_object_ref (source_image));
}
void
debug_dump_keyboard_shortcuts_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
PikaDisplay *display;
PikaUIManager *manager;
GList *group_it;
GList *strings = NULL;
return_if_no_display (display, data);
manager = menus_get_image_manager_singleton (display->pika);
/* Gather formatted strings of keyboard shortcuts */
for (group_it = pika_ui_manager_get_action_groups (manager);
group_it;
group_it = g_list_next (group_it))
{
PikaActionGroup *group = group_it->data;
GList *actions = NULL;
GList *action_it = NULL;
actions = pika_action_group_list_actions (group);
actions = g_list_sort (actions, (GCompareFunc) pika_action_name_compare);
for (action_it = actions; action_it; action_it = g_list_next (action_it))
{
gchar **accels;
PikaAction *action = action_it->data;
const gchar *name = pika_action_get_name (action);
if (name[0] == '<')
continue;
accels = pika_action_get_display_accels (action);
if (accels && accels[0])
{
const gchar *label_tmp;
gchar *label;
label_tmp = pika_action_get_label (action);
label = pika_strip_uline (label_tmp);
strings = g_list_prepend (strings,
g_strdup_printf ("%-20s %s",
accels[0], label));
g_free (label);
for (gint i = 1; accels[i] != NULL; i++)
strings = g_list_prepend (strings, g_strdup (accels[i]));
}
g_strfreev (accels);
}
g_list_free (actions);
}
/* Sort and prints the strings */
{
GList *string_it = NULL;
strings = g_list_sort (strings, (GCompareFunc) strcmp);
for (string_it = strings; string_it; string_it = g_list_next (string_it))
{
g_print ("%s\n", (gchar *) string_it->data);
g_free (string_it->data);
}
g_list_free (strings);
}
}
void
debug_dump_attached_data_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data)
{
Pika *pika = action_data_get_pika (data);
PikaContext *user_context = pika_get_user_context (pika);
debug_print_qdata (PIKA_OBJECT (pika));
debug_print_qdata (PIKA_OBJECT (user_context));
}
/* private functions */
static gboolean
debug_benchmark_projection (PikaDisplay *display)
{
PikaImage *image = pika_display_get_image (display);
if (image)
{
PikaProjection *projection = pika_image_get_projection (image);
pika_projection_stop_rendering (projection);
PIKA_TIMER_START ();
pika_image_invalidate_all (image);
pika_projection_flush_now (projection, TRUE);
PIKA_TIMER_END ("Validation of the entire projection");
g_object_unref (display);
}
return FALSE;
}
static gboolean
debug_show_image_graph (PikaImage *source_image)
{
GeglNode *image_graph;
GeglNode *output_node;
PikaImage *new_image;
GeglNode *introspect;
GeglNode *sink;
GeglBuffer *buffer = NULL;
image_graph = pika_projectable_get_graph (PIKA_PROJECTABLE (source_image));
output_node = gegl_node_get_output_proxy (image_graph, "output");
introspect = gegl_node_new_child (NULL,
"operation", "gegl:introspect",
"node", output_node,
NULL);
sink = gegl_node_new_child (NULL,
"operation", "gegl:buffer-sink",
"buffer", &buffer,
NULL);
gegl_node_link_many (introspect, sink, NULL);
gegl_node_process (sink);
if (buffer)
{
gchar *new_name;
/* This should not happen but "gegl:introspect" is a bit fickle as
* it uses an external binary `dot`. Prevent useless crashes.
* I don't output a warning when buffer is NULL because anyway
* GEGL will output one itself.
*/
new_name = g_strdup_printf ("%s GEGL graph",
pika_image_get_display_name (source_image));
new_image = pika_create_image_from_buffer (source_image->pika,
buffer, new_name);
pika_image_set_file (new_image, g_file_new_for_uri (new_name));
g_free (new_name);
g_object_unref (buffer);
}
g_object_unref (sink);
g_object_unref (introspect);
g_object_unref (source_image);
return FALSE;
}
static void
debug_print_qdata (PikaObject *object)
{
g_print ("\nData attached to '%s':\n\n", pika_object_get_name (object));
g_datalist_foreach (&G_OBJECT (object)->qdata,
debug_print_qdata_foreach,
NULL);
g_print ("\n");
}
static void
debug_print_qdata_foreach (GQuark key_id,
gpointer data,
gpointer user_data)
{
g_print ("%s: %p\n", g_quark_to_string (key_id), data);
}

View File

@ -0,0 +1,49 @@
/* 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/>.
*/
#ifndef __DEBUG_COMMANDS_H__
#define __DEBUG_COMMANDS_H__
void debug_gtk_inspector_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void debug_mem_profile_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void debug_benchmark_projection_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void debug_show_image_graph_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void debug_dump_menus_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void debug_dump_keyboard_shortcuts_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
void debug_dump_attached_data_cmd_callback (PikaAction *action,
GVariant *value,
gpointer data);
#endif /* __DEBUG_COMMANDS_H__ */

View File

@ -0,0 +1,456 @@
/* 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),