示例#1
0
static void
check_drawables (GimpDrawable *drawable)
{
  gint i;

  /* Check that boxmap images are valid */
  /* ================================== */

  for (i = 0; i < 6; i++)
    {
      if (mapvals.boxmap_id[i] == -1 ||
          !gimp_item_is_valid (mapvals.boxmap_id[i]) ||
          gimp_drawable_is_gray (mapvals.boxmap_id[i]))
        mapvals.boxmap_id[i] = drawable->drawable_id;
    }

  /* Check that cylindermap images are valid */
  /* ======================================= */

  for (i = 0; i < 2; i++)
    {
      if (mapvals.cylindermap_id[i] == -1 ||
          !gimp_item_is_valid (mapvals.cylindermap_id[i]) ||
          gimp_drawable_is_gray (mapvals.cylindermap_id[i]))
        mapvals.cylindermap_id[i] = drawable->drawable_id;
    }
}
示例#2
0
PyObject *
pygimp_item_new(gint32 ID)
{
    PyObject *self;

    if (!gimp_item_is_valid(ID)) {
        Py_INCREF(Py_None);
        return Py_None;
    }

    /* create the appropriate object type */
    if (gimp_item_is_drawable(ID)) {
        if (gimp_item_is_group(ID)) {
            self = pygimp_group_layer_new(ID);
        }
        else {
            self = pygimp_drawable_new(NULL, ID);
        }
    }
    else /* Vectors */
        self = pygimp_vectors_new(ID);

    if (self == NULL)
        return NULL;

    return self;
}
示例#3
0
文件: print.c 项目: DevMaggio/gimp
static void
end_print (GtkPrintOperation *operation,
           GtkPrintContext   *context,
           gint32            *layer_ID)
{
  /* we don't need the print layer any longer, delete it */
  if (gimp_item_is_valid (*layer_ID))
    {
      gimp_item_delete (*layer_ID);
      *layer_ID = -1;
    }

  gimp_progress_end ();

  /* generate events to solve the problems described in bug #466928 */
  g_timeout_add_seconds (1, (GSourceFunc) gtk_true, NULL);
}
PyObject *
pygimp_vectors_new(gint32 ID)
{
    PyGimpVectors *self;

    if (!gimp_item_is_valid(ID)) {
        Py_INCREF(Py_None);
        return Py_None;
    }

    self = PyObject_NEW(PyGimpVectors, &PyGimpVectors_Type);

    if (self == NULL)
        return NULL;

    self->ID = ID;

    return (PyObject *)self;
}
示例#5
0
文件: jpeg-save.c 项目: frne/gimp
void
destroy_preview (void)
{
  if (prev_p && !prev_p->abort_me)
    {
      guint id = prev_p->source_id;
      prev_p->abort_me = TRUE;   /* signal the background save to stop */
      background_jpeg_save (prev_p);
      g_source_remove (id);
    }

  if (gimp_image_is_valid (preview_image_ID) &&
      gimp_item_is_valid (preview_layer_ID))
    {
      /*  assuming that reference counting is working correctly,
          we do not need to delete the layer, removing it from
          the image should be sufficient  */
      gimp_image_remove_layer (preview_image_ID, preview_layer_ID);

      preview_layer_ID = -1;
    }
}
示例#6
0
/**
 * gimp_drawable_is_valid:
 * @drawable_ID: The drawable to check.
 *
 * Deprecated: Use gimp_item_is_valid() instead.
 *
 * Returns: Whether the drawable ID is valid.
 *
 * Since: GIMP 2.4
 */
gboolean
gimp_drawable_is_valid (gint32 drawable_ID)
{
  return gimp_item_is_valid (drawable_ID);
}
示例#7
0
/**
 * gimp_vectors_is_valid:
 * @vectors_ID: The vectors object to check.
 *
 * Deprecated: Use gimp_item_is_valid() instead.
 *
 * Returns: Whether the vectors ID is valid.
 *
 * Since: GIMP 2.4
 */
gboolean
gimp_vectors_is_valid (gint32 vectors_ID)
{
  return gimp_item_is_valid (vectors_ID);
}
示例#8
0
文件: print.c 项目: DevMaggio/gimp
static GimpPDBStatusType
print_image (gint32     image_ID,
             gboolean   interactive,
             GError   **error)
{
  GtkPrintOperation       *operation;
  GtkPrintOperationResult  result;
  gint32                   layer;
  PrintData                data;

  /*  create a print layer from the projection  */
  layer = gimp_layer_new_from_visible (image_ID, image_ID, PRINT_PROC_NAME);

  operation = gtk_print_operation_new ();

  gtk_print_operation_set_n_pages (operation, 1);
  print_operation_set_name (operation, image_ID);

  print_page_setup_load (operation, image_ID);

  /* fill in the PrintData struct */
  data.image_id        = image_ID;
  data.drawable_id     = layer;
  data.unit            = gimp_get_default_unit ();
  data.image_unit      = gimp_image_get_unit (image_ID);
  data.offset_x        = 0;
  data.offset_y        = 0;
  data.center          = CENTER_BOTH;
  data.use_full_page   = FALSE;
  data.draw_crop_marks = FALSE;
  data.operation       = operation;

  gimp_image_get_resolution (image_ID, &data.xres, &data.yres);

  print_settings_load (&data);

  gtk_print_operation_set_unit (operation, GTK_UNIT_PIXEL);

  g_signal_connect (operation, "begin-print",
                    G_CALLBACK (begin_print),
                    &data);
  g_signal_connect (operation, "draw-page",
                    G_CALLBACK (draw_page),
                    &data);
  g_signal_connect (operation, "end-print",
                    G_CALLBACK (end_print),
                    &layer);

  if (interactive)
    {
      gimp_ui_init (PLUG_IN_BINARY, FALSE);

      g_signal_connect_swapped (operation, "end-print",
                                G_CALLBACK (print_settings_save),
                                &data);

      g_signal_connect (operation, "create-custom-widget",
                        G_CALLBACK (create_custom_widget),
                        &data);

      gtk_print_operation_set_custom_tab_label (operation, _("Image Settings"));

      gtk_print_operation_set_embed_page_setup (operation, TRUE);

      result = gtk_print_operation_run (operation,
                                        GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                        NULL, error);

      if (result == GTK_PRINT_OPERATION_RESULT_APPLY ||
          result == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS)
        {
          print_page_setup_save (operation, image_ID);
        }
    }
  else
    {
      result = gtk_print_operation_run (operation,
                                        GTK_PRINT_OPERATION_ACTION_PRINT,
                                        NULL, error);
    }

  g_object_unref (operation);

  if (gimp_item_is_valid (layer))
    gimp_item_delete (layer);

  switch (result)
    {
    case GTK_PRINT_OPERATION_RESULT_APPLY:
    case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
      return GIMP_PDB_SUCCESS;

    case GTK_PRINT_OPERATION_RESULT_CANCEL:
      return GIMP_PDB_CANCEL;

    case GTK_PRINT_OPERATION_RESULT_ERROR:
      return GIMP_PDB_EXECUTION_ERROR;
    }

  return GIMP_PDB_EXECUTION_ERROR;
}