Example #1
0
void
documents_actions_update (GimpActionGroup *group,
                          gpointer         data)
{
  GimpContext   *context;
  GimpImagefile *imagefile = NULL;

  context = action_data_get_context (data);

  if (context)
    imagefile = gimp_context_get_imagefile (context);

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

  SET_SENSITIVE ("documents-open",                 imagefile);
  SET_SENSITIVE ("documents-raise-or-open",        imagefile);
  SET_SENSITIVE ("documents-file-open-dialog",     TRUE);
  SET_SENSITIVE ("documents-copy-location",        imagefile);
  SET_SENSITIVE ("documents-show-in-file-manager", imagefile);
  SET_SENSITIVE ("documents-remove",               imagefile);
  SET_SENSITIVE ("documents-clear",                TRUE);
  SET_SENSITIVE ("documents-recreate-preview",     imagefile);
  SET_SENSITIVE ("documents-reload-previews",      imagefile);
  SET_SENSITIVE ("documents-remove-dangling",      imagefile);

#undef SET_SENSITIVE
}
Example #2
0
void
documents_show_in_file_manager_cmd_callback (GtkAction *action,
                                             gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  imagefile = gimp_context_get_imagefile (context);

  if (imagefile)
    {
      GFile  *file  = g_file_new_for_uri (gimp_object_get_name (imagefile));
      GError *error = NULL;

      if (! gimp_file_show_in_file_manager (file, &error))
        {
          gimp_message (context->gimp, G_OBJECT (editor),
                        GIMP_MESSAGE_ERROR,
                        _("Can't show file in file manager: %s"),
                        error->message);
          g_clear_error (&error);
        }

      g_object_unref (file);
    }
}
Example #3
0
void
documents_recreate_preview_cmd_callback (GtkAction *action,
                                         gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      GError *error = NULL;

      if (! gimp_imagefile_create_thumbnail (imagefile,
                                             context, NULL,
                                             context->gimp->config->thumbnail_size,
                                             FALSE, &error))
        {
          gimp_message_literal (context->gimp,
                                NULL , GIMP_MESSAGE_ERROR,
                                error->message);
          g_clear_error (&error);
        }
    }
}
Example #4
0
void
documents_raise_or_open_cmd_callback (GtkAction *action,
                                      gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      RaiseClosure closure;

      closure.name  = gimp_object_get_name (imagefile);
      closure.found = FALSE;

      gimp_container_foreach (context->gimp->displays,
                              (GFunc) documents_raise_display,
                              &closure);

      if (! closure.found)
        documents_open_image (GTK_WIDGET (editor), context, imagefile);
    }
}
Example #5
0
void
documents_remove_cmd_callback (GtkAction *action,
                               gpointer   data)
{
  GimpContainerEditor *editor  = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context = gimp_container_view_get_context (editor->view);
  GimpImagefile       *imagefile = gimp_context_get_imagefile (context);
  const gchar         *uri;

  uri = gimp_object_get_name (imagefile);

  gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, NULL);

  gimp_container_view_remove_active (editor->view);
}
Example #6
0
void
documents_copy_location_cmd_callback (GtkAction *action,
                                      gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  imagefile = gimp_context_get_imagefile (context);

  if (imagefile)
    gimp_clipboard_set_text (context->gimp,
                             gimp_object_get_name (imagefile));
}
Example #7
0
void
documents_file_open_dialog_cmd_callback (GtkAction *action,
                                         gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      file_file_open_dialog (context->gimp,
                             gimp_imagefile_get_file (imagefile),
                             GTK_WIDGET (editor));
    }
}
Example #8
0
void
documents_recreate_preview_cmd_callback (GtkAction *action,
                                         gpointer   data)
{
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContext         *context;
  GimpContainer       *container;
  GimpImagefile       *imagefile;

  context   = gimp_container_view_get_context (editor->view);
  container = gimp_container_view_get_container (editor->view);

  imagefile = gimp_context_get_imagefile (context);

  if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile)))
    {
      gimp_imagefile_create_thumbnail (imagefile,
                                       context, NULL,
                                       context->gimp->config->thumbnail_size,
                                       FALSE);
    }
}