app: reimplement the stuff reverted below

but stay completely in filter-actions.c and filters-menus.c
This commit is contained in:
Michael Natterer 2023-05-25 02:30:29 +02:00
parent 4209a584fc
commit fa2e9adc29
3 changed files with 88 additions and 3 deletions

View File

@ -18,12 +18,15 @@
#include "config.h"
#include <gegl.h>
#include <gegl-plugin.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "gegl/gimp-gegl-utils.h"
#include "core/gimp-filter-history.h"
#include "core/gimpimage.h"
#include "core/gimplayermask.h"
@ -34,6 +37,7 @@
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h"
#include "actions.h"
#include "filters-actions.h"
@ -747,6 +751,8 @@ filters_actions_setup (GimpActionGroup *group)
GimpProcedureActionEntry *entries;
gint n_entries;
gint i;
GList *op_classes;
GList *iter;
gimp_action_group_add_string_actions (group, "filters-action",
filters_actions,
@ -769,6 +775,51 @@ filters_actions_setup (GimpActionGroup *group)
filters_actions_set_tooltips (group, filters_interactive_actions,
G_N_ELEMENTS (filters_interactive_actions));
op_classes = gimp_gegl_get_op_classes ();
for (iter = op_classes; iter; iter = iter->next)
{
GeglOperationClass *op_class = GEGL_OPERATION_CLASS (iter->data);
GimpStringActionEntry entry = { 0, };
gchar *formatted_op_name;
gchar *action_name;
const gchar *title;
const gchar *op_name;
gchar *label;
formatted_op_name = g_strdup (op_class->name);
gimp_make_valid_action_name (formatted_op_name);
action_name = g_strdup_printf ("filters-%s", formatted_op_name);
g_free (formatted_op_name);
title = gegl_operation_class_get_key (op_class, "title");
op_name = op_class->name;
if (g_str_has_prefix (op_name, "gegl:"))
op_name += strlen ("gegl:");
if (title)
label = g_strdup_printf ("%s (%s)", title, op_name);
else
label = g_strdup (op_name);
entry.name = action_name;
entry.icon_name = GIMP_ICON_GEGL;
entry.label = label;
entry.tooltip = gegl_operation_class_get_key (op_class, "description");
entry.value = op_class->name;
entry.help_id = GIMP_HELP_TOOL_GEGL;
gimp_action_group_add_string_actions (group, "filters-action",
&entry, 1,
filters_apply_interactive_cmd_callback);
g_free (label);
g_free (action_name);
}
g_list_free (op_classes);
gimp_action_group_add_enum_actions (group, "filters-action",
filters_repeat_actions,
G_N_ELEMENTS (filters_repeat_actions),

View File

@ -18,14 +18,18 @@
#include "config.h"
#include <gegl.h>
#include <gegl-plugin.h>
#include <gtk/gtk.h>
#include "menus-types.h"
#include "gegl/gimp-gegl-utils.h"
#include "core/gimp.h"
#include "core/gimp-filter-history.h"
#include "widgets/gimpuimanager.h"
#include "widgets/gimpwidgets-utils.h"
#include "filters-menu.h"
@ -36,6 +40,8 @@ void
filters_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
GList *op_classes;
GList *iter;
gint i;
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
@ -52,4 +58,25 @@ filters_menu_setup (GimpUIManager *manager,
g_free (action_name);
}
op_classes = gimp_gegl_get_op_classes ();
for (iter = op_classes; iter; iter = iter->next)
{
GeglOperationClass *opclass = GEGL_OPERATION_CLASS (iter->data);
gchar *formatted_op_name;
gchar *action_name;
formatted_op_name = g_strdup (opclass->name);
gimp_make_valid_action_name (formatted_op_name);
action_name = g_strdup_printf ("filters-%s", formatted_op_name);
g_free (formatted_op_name);
gimp_ui_manager_add_ui (manager, "/Filters/GEGL Operations",
action_name, NULL, FALSE);
g_free (action_name);
}
g_list_free (op_classes);
}

View File

@ -605,6 +605,9 @@
<item><attribute name="action">app.tools-measure</attribute></item>
<item><attribute name="action">app.tools-zoom</attribute></item>
</section>
<section>
<item><attribute name="action">app.tools-gegl</attribute></item>
</section>
<section>
<item><attribute name="action">app.dialogs-toolbox</attribute></item>
<item><attribute name="action">app.context-colors-default</attribute></item>
@ -711,12 +714,16 @@
<attribute name="label" translatable="yes" context="filters-action">_Generic</attribute>
<item><attribute name="action">app.filters-convolution-matrix</attribute></item>
<item><attribute name="action">app.filters-distance-map</attribute></item>
<item><attribute name="action">app.tools-gegl</attribute></item>
<item><attribute name="action">app.filters-gegl-graph</attribute></item>
<item><attribute name="action">app.filters-normal-map</attribute></item>
<item><attribute name="action">app.filters-dilate</attribute></item>
<item><attribute name="action">app.filters-erode</attribute></item>
</submenu>
<submenu>
<attribute name="label" translatable="yes" context="filters-action">_GEGL Operations</attribute>
<section>
<item><attribute name="action">app.filters-gegl-graph</attribute></item>
</section>
</submenu>
<submenu>
<attribute name="label" translatable="yes" context="filters-action">C_ombine</attribute>
<!-- TODO Miss: all plug-ins -->