Пример #1
0
void
tool_presets_actions_update (GimpActionGroup *group,
                             gpointer         user_data)
{
  GimpContext    *context     = action_data_get_context (user_data);
  GimpToolPreset *tool_preset = NULL;
  GimpData       *data        = NULL;
  GFile          *file        = NULL;

  if (context)
    {
      tool_preset = gimp_context_get_tool_preset (context);

      if (tool_preset)
        {
          data = GIMP_DATA (tool_preset);

          file = gimp_data_get_file (data);
        }
    }

#define SET_SENSITIVE(action,condition) \
        gimp_action_group_set_action_sensitive (group, action, (condition) != 0)

  SET_SENSITIVE ("tool-presets-edit",                 tool_preset);
  SET_SENSITIVE ("tool-presets-duplicate",            tool_preset && GIMP_DATA_GET_CLASS (data)->duplicate);
  SET_SENSITIVE ("tool-presets-copy-location",        file);
  SET_SENSITIVE ("tool-presets-show-in-file-manager", file);
  SET_SENSITIVE ("tool-presets-restore",              tool_preset);
  SET_SENSITIVE ("tool-presets-delete",               tool_preset && gimp_data_is_deletable (data));

#undef SET_SENSITIVE
}
Пример #2
0
void
tool_presets_save_cmd_callback (GtkAction *action,
                                gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpToolPreset      *preset;
  GimpToolInfo        *tool_info;

  context = gimp_container_view_get_context (editor->view);

  preset    = gimp_context_get_tool_preset (context);
  tool_info = gimp_context_get_tool (gimp_get_user_context (context->gimp));

  if (tool_info && preset)
    {
      GimpToolInfo *preset_tool;

      preset_tool =  gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));

      if (tool_info != preset_tool)
        {
          gimp_message (context->gimp,
                        G_OBJECT (editor), GIMP_MESSAGE_WARNING,
                        _("Can't save '%s' tool options to an "
                          "existing '%s' tool preset."),
                        tool_info->blurb,
                        preset_tool->blurb);
          return;
        }

      gimp_config_sync (G_OBJECT (tool_info->tool_options),
                        G_OBJECT (preset->tool_options), 0);
    }
}
Пример #3
0
void
tool_presets_restore_cmd_callback (GtkAction *action,
                                   gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpToolPreset      *preset;

  context = gimp_container_view_get_context (editor->view);

  preset = gimp_context_get_tool_preset (context);

  if (preset)
    gimp_context_tool_preset_changed (gimp_get_user_context (context->gimp));
}
GtkWidget *
gimp_tool_preset_editor_new (GimpContext     *context,
                             GimpMenuFactory *menu_factory)
{
    g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
    g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);

    return g_object_new (GIMP_TYPE_TOOL_PRESET_EDITOR,
                         "menu-factory",    menu_factory,
                         "menu-identifier", "<ToolPresetEditor>",
                         "ui-path",         "/tool-preset-editor-popup",
                         "data-factory",    context->gimp->tool_preset_factory,
                         "context",         context,
                         "data",            gimp_context_get_tool_preset (context),
                         NULL);
}
Пример #5
0
void
tool_options_restore_preset_cmd_callback (GtkAction *action,
        gint       value,
        gpointer   data)
{
    GimpEditor     *editor    = GIMP_EDITOR (data);
    Gimp           *gimp      = gimp_editor_get_ui_manager (editor)->gimp;
    GimpContext    *context   = gimp_get_user_context (gimp);
    GimpToolInfo   *tool_info = gimp_context_get_tool (context);
    GimpToolPreset *preset;

    preset = (GimpToolPreset *)
             gimp_container_get_child_by_index (tool_info->presets, value);

    if (preset)
    {
        if (gimp_context_get_tool_preset (context) != preset)
            gimp_context_set_tool_preset (context, preset);
        else
            gimp_context_tool_preset_changed (context);
    }
}