コード例 #1
0
ファイル: gimpdisplay.c プロジェクト: Amerekanets/gimp
static guint32
gimp_display_progress_get_window (GimpProgress *progress)
{
  GimpDisplay *display = GIMP_DISPLAY (progress);

  if (display->shell)
    return gimp_progress_get_window (GIMP_PROGRESS (display->shell));

  return 0;
}
コード例 #2
0
ファイル: gimptool-progress.c プロジェクト: frne/gimp
static gdouble
gimp_tool_progress_get_value (GimpProgress *progress)
{
  GimpTool *tool = GIMP_TOOL (progress);

  if (tool->progress)
    return gimp_progress_get_value (GIMP_PROGRESS (tool->progress));

  return 0.0;
}
コード例 #3
0
ファイル: gimpdisplay.c プロジェクト: Amerekanets/gimp
static gdouble
gimp_display_progress_get_value (GimpProgress *progress)
{
  GimpDisplay *display = GIMP_DISPLAY (progress);

  if (display->shell)
    return gimp_progress_get_value (GIMP_PROGRESS (display->shell));

  return 0.0;
}
コード例 #4
0
ファイル: gimpdisplay.c プロジェクト: Amerekanets/gimp
static gboolean
gimp_display_progress_is_active (GimpProgress *progress)
{
  GimpDisplay *display = GIMP_DISPLAY (progress);

  if (display->shell)
    return gimp_progress_is_active (GIMP_PROGRESS (display->shell));

  return FALSE;
}
コード例 #5
0
ファイル: file-open.c プロジェクト: Distrotech/gimp
/*  This function is called for filenames passed on the command-line
 *  or from the D-Bus service.
 */
gboolean
file_open_from_command_line (Gimp     *gimp,
                             GFile    *file,
                             gboolean  as_new,
                             GObject  *screen,
                             gint      monitor)

{
  GimpImage         *image;
  GimpObject        *display;
  GimpPDBStatusType  status;
  gboolean           success = FALSE;
  GError            *error   = NULL;

  g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
  g_return_val_if_fail (G_IS_FILE (file), FALSE);
  g_return_val_if_fail (screen == NULL || G_IS_OBJECT (screen), FALSE);

  display = gimp_get_empty_display (gimp);

  /* show the progress in the last opened display, see bug #704896 */
  if (! display)
    display = gimp_context_get_display (gimp_get_user_context (gimp));

  if (display)
    g_object_add_weak_pointer (G_OBJECT (display), (gpointer) &display);

  image = file_open_with_display (gimp,
                                  gimp_get_user_context (gimp),
                                  GIMP_PROGRESS (display),
                                  file, as_new,
                                  screen, monitor,
                                  &status, &error);

  if (image)
    {
      success = TRUE;

      g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_FILE_KEY,
                              g_object_ref (file),
                              (GDestroyNotify) g_object_unref);
    }
  else if (status != GIMP_PDB_CANCEL && display)
    {
      gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
                    _("Opening '%s' failed: %s"),
                    gimp_file_get_utf8_name (file), error->message);
      g_clear_error (&error);
    }

  if (display)
    g_object_remove_weak_pointer (G_OBJECT (display), (gpointer) &display);

  return success;
}
コード例 #6
0
ファイル: file-commands.c プロジェクト: 1ynx/gimp
void
file_open_recent_cmd_callback (GtkAction *action,
                               gint       value,
                               gpointer   data)
{
  Gimp          *gimp;
  GimpImagefile *imagefile;
  gint           num_entries;
  return_if_no_gimp (gimp, data);

  num_entries = gimp_container_get_n_children (gimp->documents);

  if (value >= num_entries)
    return;

  imagefile = (GimpImagefile *)
    gimp_container_get_child_by_index (gimp->documents, value);

  if (imagefile)
    {
      GimpDisplay       *display;
      GimpProgress      *progress;
      GimpImage         *image;
      GimpPDBStatusType  status;
      GError            *error = NULL;
      return_if_no_display (display, data);

      g_object_ref (display);
      g_object_ref (imagefile);

      progress = gimp_display_get_image (display) ?
                 NULL : GIMP_PROGRESS (display);

      image = file_open_with_display (gimp, action_data_get_context (data),
                                      progress,
                                      gimp_object_get_name (imagefile), FALSE,
                                      &status, &error);

      if (! image && status != GIMP_PDB_CANCEL)
        {
          gchar *filename =
            file_utils_uri_display_name (gimp_object_get_name (imagefile));

          gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
                        _("Opening '%s' failed:\n\n%s"),
                        filename, error->message);
          g_clear_error (&error);

          g_free (filename);
        }

      g_object_unref (imagefile);
      g_object_unref (display);
    }
}
コード例 #7
0
ファイル: gimpthumbbox.c プロジェクト: Amerekanets/gimp
static gboolean
gimp_thumb_box_auto_thumbnail (GimpThumbBox *box)
{
  Gimp          *gimp  = box->imagefile->gimp;
  GimpThumbnail *thumb = box->imagefile->thumbnail;
  const gchar   *uri   = gimp_object_get_name (GIMP_OBJECT (box->imagefile));

  box->idle_id = 0;

  if (thumb->image_state == GIMP_THUMB_STATE_NOT_FOUND)
    return FALSE;

  switch (thumb->thumb_state)
    {
    case GIMP_THUMB_STATE_NOT_FOUND:
    case GIMP_THUMB_STATE_OLD:
      if (thumb->image_filesize < gimp->config->thumbnail_filesize_limit &&
          ! gimp_thumbnail_has_failed (thumb)                            &&
          file_procedure_find_by_extension (gimp->plug_in_manager->load_procs,
                                            uri))
        {
          if (thumb->image_filesize > 0)
            {
              gchar *size;
              gchar *text;

              size = gimp_memsize_to_string (thumb->image_filesize);
              text = g_strdup_printf ("%s\n%s",
                                      size, _("Creating preview..."));

              gtk_label_set_text (GTK_LABEL (box->info), text);

              g_free (text);
              g_free (size);
            }
          else
            {
              gtk_label_set_text (GTK_LABEL (box->info),
                                  _("Creating preview..."));
            }

          gimp_imagefile_create_thumbnail_weak (box->imagefile, box->context,
                                                GIMP_PROGRESS (box),
                                                gimp->config->thumbnail_size,
                                                TRUE);
        }
      break;

    default:
      break;
    }

  return FALSE;
}
コード例 #8
0
void
help_help_cmd_callback (GtkAction *action,
                        gpointer   data)
{
  Gimp        *gimp;
  GimpDisplay *display;
  return_if_no_gimp (gimp, data);
  return_if_no_display (display, data);

  gimp_help_show (gimp, GIMP_PROGRESS (display), NULL, NULL);
}
コード例 #9
0
ファイル: gimpprogressdialog.c プロジェクト: Amerekanets/gimp
static void
gimp_progress_dialog_progress_set_text (GimpProgress *progress,
                                        const gchar  *message)
{
  GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);

  if (! dialog->box)
    return;

  gimp_progress_set_text (GIMP_PROGRESS (dialog->box), message);
}
コード例 #10
0
ファイル: gimpprogressdialog.c プロジェクト: Amerekanets/gimp
static void
gimp_progress_dialog_progress_set_value (GimpProgress *progress,
                                         gdouble       percentage)
{
  GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);

  if (! dialog->box)
    return;

  gimp_progress_set_value (GIMP_PROGRESS (dialog->box), percentage);
}
コード例 #11
0
ファイル: vectors-commands.c プロジェクト: ellelstone/gimp
void
vectors_selection_to_vectors_cmd_callback (GtkAction *action,
                                           gint       value,
                                           gpointer   data)
{
  GimpImage      *image;
  GtkWidget      *widget;
  GimpProcedure  *procedure;
  GimpValueArray *args;
  GimpDisplay    *display;
  GError         *error = NULL;
  return_if_no_image (image, data);
  return_if_no_widget (widget, data);

  if (value)
    procedure = gimp_pdb_lookup_procedure (image->gimp->pdb,
                                           "plug-in-sel2path-advanced");
  else
    procedure = gimp_pdb_lookup_procedure (image->gimp->pdb,
                                           "plug-in-sel2path");

  if (! procedure)
    {
      gimp_message_literal (image->gimp,
                            G_OBJECT (widget), GIMP_MESSAGE_ERROR,
                            "Selection to path procedure lookup failed.");
      return;
    }

  display = gimp_context_get_display (action_data_get_context (data));

  args = gimp_procedure_get_arguments (procedure);
  gimp_value_array_truncate (args, 2);

  g_value_set_int      (gimp_value_array_index (args, 0),
                        GIMP_RUN_INTERACTIVE);
  gimp_value_set_image (gimp_value_array_index (args, 1),
                        image);

  gimp_procedure_execute_async (procedure, image->gimp,
                                action_data_get_context (data),
                                GIMP_PROGRESS (display), args,
                                GIMP_OBJECT (display), &error);

  gimp_value_array_unref (args);

  if (error)
    {
      gimp_message_literal (image->gimp,
                            G_OBJECT (widget), GIMP_MESSAGE_ERROR,
                            error->message);
      g_error_free (error);
    }
}
コード例 #12
0
ファイル: gimptool-progress.c プロジェクト: frne/gimp
static gboolean
gimp_tool_progress_key_press (GtkWidget         *widget,
                              const GdkEventKey *kevent,
                              GimpTool          *tool)
{
  if (kevent->keyval == GDK_KEY_Escape)
    {
      gimp_progress_cancel (GIMP_PROGRESS (tool));
    }

  return TRUE;
}
コード例 #13
0
ファイル: gimpprogress.c プロジェクト: AdamGrzonkowski/gimp-1
void
gimp_progress_update_and_flush (gint     min,
                                gint     max,
                                gint     current,
                                gpointer data)
{
  gimp_progress_set_value (GIMP_PROGRESS (data),
                           (gdouble) (current - min) / (gdouble) (max - min));

  while (g_main_context_pending (NULL))
    g_main_context_iteration (NULL, TRUE);
}
コード例 #14
0
ファイル: gimpcagetool.c プロジェクト: STRNG/gimp
static void
gimp_cage_tool_create_render_node (GimpCageTool *ct)
{
  GimpCageOptions *options  = GIMP_CAGE_TOOL_GET_OPTIONS (ct);
  GeglNode        *coef, *cage, *render; /* Render nodes */
  GeglNode        *input, *output; /* Proxy nodes*/
  GeglNode        *node; /* wraper to be returned */

  g_return_if_fail (ct->render_node == NULL);
  /* render_node is not supposed to be recreated */

  node = gegl_node_new ();

  input  = gegl_node_get_input_proxy  (node, "input");
  output = gegl_node_get_output_proxy (node, "output");

  coef = gegl_node_new_child (node,
                              "operation", "gegl:buffer-source",
                              "buffer",    ct->coef,
                              NULL);

  cage = gegl_node_new_child (node,
                              "operation",        "gimp:cage-transform",
                              "config",           ct->config,
                              "fill_plain_color", options->fill_plain_color,
                              NULL);

  render = gegl_node_new_child (node,
                                "operation", "gegl:map-absolute",
                                NULL);

  gegl_node_connect_to (input, "output",
                        cage, "input");

  gegl_node_connect_to (coef, "output",
                        cage, "aux");

  gegl_node_connect_to (input, "output",
                        render, "input");

  gegl_node_connect_to (cage, "output",
                        render, "aux");

  gegl_node_connect_to (render, "output",
                        output, "input");

  ct->render_node = node;
  ct->cage_node = cage;
  ct->coef_node = coef;

  gimp_gegl_progress_connect (cage, GIMP_PROGRESS (ct), _("Cage Transform"));
}
コード例 #15
0
ファイル: gimpsubprogress.c プロジェクト: jiapei100/gimp
/**
 * gimp_sub_progress_new:
 * @progress: parent progress or %NULL
 *
 * GimpSubProgress implements the GimpProgress interface and can be
 * used wherever a GimpProgress is needed. It maps progress
 * information to a sub-range of its parent @progress. This is useful
 * when an action breaks down into multiple sub-actions that itself
 * need a #GimpProgress pointer. See gimp_image_scale() for an example.
 *
 * Return value: a new #GimpProgress object
 */
GimpProgress *
gimp_sub_progress_new (GimpProgress *progress)
{
  GimpSubProgress *sub;

  g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);

  sub = g_object_new (GIMP_TYPE_SUB_PROGRESS,
                      "progress", progress,
                      NULL);

  return GIMP_PROGRESS (sub);
}
コード例 #16
0
ファイル: gimpdisplay.c プロジェクト: Amerekanets/gimp
static GimpProgress *
gimp_display_progress_start (GimpProgress *progress,
                             const gchar  *message,
                             gboolean      cancelable)
{
  GimpDisplay *display = GIMP_DISPLAY (progress);

  if (display->shell)
    return gimp_progress_start (GIMP_PROGRESS (display->shell),
                                message, cancelable);

  return NULL;
}
コード例 #17
0
ファイル: gimptool-progress.c プロジェクト: frne/gimp
static void
gimp_tool_progress_set_text (GimpProgress *progress,
                             const gchar  *message)
{
  GimpTool *tool = GIMP_TOOL (progress);

  if (tool->progress)
    {
      GimpDisplayShell *shell = gimp_display_get_shell (tool->progress_display);

      gimp_progress_set_text (GIMP_PROGRESS (tool->progress), message);
      gimp_widget_flush_expose (shell->canvas);
    }
}
コード例 #18
0
ファイル: gimptool-progress.c プロジェクト: frne/gimp
static void
gimp_tool_progress_set_value (GimpProgress *progress,
                              gdouble       percentage)
{
  GimpTool *tool = GIMP_TOOL (progress);

  if (tool->progress)
    {
      GimpDisplayShell *shell = gimp_display_get_shell (tool->progress_display);

      gimp_progress_set_value (GIMP_PROGRESS (tool->progress), percentage);
      gimp_widget_flush_expose (shell->canvas);
    }
}
コード例 #19
0
ファイル: gimpdisplay.c プロジェクト: Amerekanets/gimp
static gboolean
gimp_display_progress_message (GimpProgress        *progress,
                               Gimp                *gimp,
                               GimpMessageSeverity  severity,
                               const gchar         *domain,
                               const gchar         *message)
{
  GimpDisplay *display = GIMP_DISPLAY (progress);

  if (display->shell)
    return gimp_progress_message (GIMP_PROGRESS (display->shell), gimp,
                                  severity, domain, message);

  return FALSE;
}
コード例 #20
0
ファイル: gimpblendtool.c プロジェクト: Anstep/gimp
static void
gimp_blend_tool_commit (GimpBlendTool *blend_tool)
{
  GimpTool *tool = GIMP_TOOL (blend_tool);

  if (blend_tool->filter)
    {
      gimp_drawable_filter_commit (blend_tool->filter,
                                   GIMP_PROGRESS (tool), FALSE);
      g_object_unref (blend_tool->filter);
      blend_tool->filter = NULL;

      gimp_image_flush (gimp_display_get_image (tool->display));
    }
}
コード例 #21
0
void
drawable_value_invert_cmd_callback (GtkAction *action,
                                    gpointer   data)
{
  GimpImage    *image;
  GimpDrawable *drawable;
  GimpDisplay  *display;
  return_if_no_drawable (image, drawable, data);
  return_if_no_display (display, data);

  gimp_drawable_apply_operation_by_name (drawable, GIMP_PROGRESS (display),
                                         _("Invert"), "gegl:value-invert",
                                         NULL);
  gimp_image_flush (image);
}
コード例 #22
0
ファイル: gimpseamlessclonetool.c プロジェクト: alfanak/gimp
static gboolean
gimp_seamless_clone_tool_key_press (GimpTool    *tool,
                                    GdkEventKey *kevent,
                                    GimpDisplay *display)
{
  GimpSeamlessCloneTool *sct = GIMP_SEAMLESS_CLONE_TOOL (tool);

  if (sct->tool_state == SC_STATE_RENDER_MOTION ||
      sct->tool_state == SC_STATE_RENDER_WAIT)
    {
      switch (kevent->keyval)
        {
        case GDK_KEY_Return:
        case GDK_KEY_KP_Enter:
        case GDK_KEY_ISO_Enter:
          gimp_tool_control_set_preserve (tool->control, TRUE);

          /* TODO: there may be issues with committing the image map
           *       result after some changes were made and the preview
           *       was scrolled. We can fix these by either invalidating
           *       the area which is a union of the previous paste
           *       rectangle each time (in the update function) or by
           *       invalidating and re-rendering all now (expensive and
           *       perhaps useless */
          gimp_image_map_commit (sct->image_map, GIMP_PROGRESS (tool));
          g_object_unref (sct->image_map);
          sct->image_map = NULL;

          gimp_tool_control_set_preserve (tool->control, FALSE);

          gimp_image_flush (gimp_display_get_image (display));

          gimp_seamless_clone_tool_control (tool, GIMP_TOOL_ACTION_HALT,
                                            display);
          return TRUE;

        case GDK_KEY_Escape:
          gimp_seamless_clone_tool_control (tool, GIMP_TOOL_ACTION_HALT,
                                            display);
          return TRUE;

        default:
          break;
        }
    }

  return FALSE;
}
コード例 #23
0
ファイル: image-commands.c プロジェクト: jdburton/gimp-osx
static void
image_resize_callback (GtkWidget    *dialog,
                       GimpViewable *viewable,
                       gint          width,
                       gint          height,
                       GimpUnit      unit,
                       gint          offset_x,
                       gint          offset_y,
                       GimpItemSet   layer_set,
                       gpointer      data)
{
  ImageResizeOptions *options = data;

  image_resize_unit = unit;

  if (width > 0 && height > 0)
    {
      GimpImage    *image   = GIMP_IMAGE (viewable);
      GimpDisplay  *display = options->display;
      GimpContext  *context = options->context;
      GimpProgress *progress;

      gtk_widget_destroy (dialog);

      if (width  == gimp_image_get_width  (image) &&
          height == gimp_image_get_height (image))
        return;

      progress = gimp_progress_start (GIMP_PROGRESS (display),
                                      _("Resizing"), FALSE);

      gimp_image_resize_with_layers (image,
                                     context,
                                     width, height, offset_x, offset_y,
                                     layer_set,
                                     progress);

      if (progress)
        gimp_progress_end (progress);

      gimp_image_flush (image);
    }
  else
    {
      g_warning ("Resize Error: "
                 "Both width and height must be greater than zero.");
    }
}
コード例 #24
0
ファイル: gimpcagetool.c プロジェクト: STRNG/gimp
static void
gimp_cage_tool_commit (GimpCageTool *ct)
{
  GimpTool *tool = GIMP_TOOL (ct);

  gimp_tool_control_push_preserve (tool->control, TRUE);

  gimp_image_map_commit (ct->image_map,
                         GIMP_PROGRESS (tool));
  g_object_unref (ct->image_map);
  ct->image_map = NULL;

  gimp_tool_control_pop_preserve (tool->control);

  gimp_image_flush (gimp_display_get_image (tool->display));
}
コード例 #25
0
static void
gimp_tool_progress_end (GimpProgress *progress)
{
  GimpTool *tool = GIMP_TOOL (progress);

  if (tool->progress)
    {
      GimpDisplayShell *shell = gimp_display_get_shell (tool->progress_display);

      gimp_progress_end (GIMP_PROGRESS (tool->progress));
      gimp_display_shell_remove_item (shell, tool->progress);

      tool->progress         = NULL;
      tool->progress_display = NULL;
    }
}
コード例 #26
0
ファイル: gimptool-progress.c プロジェクト: frne/gimp
static GimpProgress *
gimp_tool_progress_start (GimpProgress *progress,
                          const gchar  *message,
                          gboolean      cancelable)
{
  GimpTool         *tool = GIMP_TOOL (progress);
  GimpDisplayShell *shell;
  gint              x, y;

  g_return_val_if_fail (GIMP_IS_DISPLAY (tool->display), NULL);
  g_return_val_if_fail (tool->progress == NULL, NULL);

  shell = gimp_display_get_shell (tool->display);

  x = shell->disp_width  / 2;
  y = shell->disp_height / 2;

  gimp_display_shell_unzoom_xy (shell, x, y, &x, &y, FALSE);

  tool->progress = gimp_canvas_progress_new (shell,
                                             GIMP_HANDLE_ANCHOR_CENTER,
                                             x, y);
  gimp_display_shell_add_unrotated_item (shell, tool->progress);
  g_object_unref (tool->progress);

  gimp_progress_start (GIMP_PROGRESS (tool->progress),
                       message, FALSE);
  gimp_widget_flush_expose (shell->canvas);

  tool->progress_display = tool->display;

  if (cancelable)
    {
      tool->progress_grab_widget = gtk_invisible_new ();
      gtk_widget_show (tool->progress_grab_widget);
      gtk_grab_add (tool->progress_grab_widget);

      g_signal_connect (tool->progress_grab_widget, "button-press-event",
                        G_CALLBACK (gimp_tool_progress_button_press),
                        tool);
      g_signal_connect (tool->progress_grab_widget, "key-press-event",
                        G_CALLBACK (gimp_tool_progress_key_press),
                        tool);
    }

  return progress;
}
コード例 #27
0
ファイル: gimpfiledialog.c プロジェクト: Amerekanets/gimp
static void
gimp_file_dialog_response (GtkDialog *dialog,
                           gint       response_id)
{
  GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);

  if (response_id != GTK_RESPONSE_OK && file_dialog->busy)
    {
      file_dialog->canceled = TRUE;

      if (GIMP_PROGRESS_BOX (file_dialog->progress)->active &&
          GIMP_PROGRESS_BOX (file_dialog->progress)->cancelable)
        {
          gimp_progress_cancel (GIMP_PROGRESS (dialog));
        }
    }
}
コード例 #28
0
ファイル: gimpfiledialog.c プロジェクト: Amerekanets/gimp
static GimpProgress *
gimp_file_dialog_progress_start (GimpProgress *progress,
                                 const gchar  *message,
                                 gboolean      cancelable)
{
  GimpFileDialog *dialog = GIMP_FILE_DIALOG (progress);
  GimpProgress   *retval;

  retval = gimp_progress_start (GIMP_PROGRESS (dialog->progress),
                                message, cancelable);
  gtk_widget_show (dialog->progress);

  gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
                                     GTK_RESPONSE_CANCEL, cancelable);

  return retval;
}
コード例 #29
0
static void
gimp_seamless_clone_tool_commit (GimpSeamlessCloneTool *sc)
{
  GimpTool *tool = GIMP_TOOL (sc);

  if (sc->filter)
    {
      gimp_tool_control_push_preserve (tool->control, TRUE);

      gimp_drawable_filter_commit (sc->filter, GIMP_PROGRESS (tool), FALSE);
      g_clear_object (&sc->filter);

      gimp_tool_control_pop_preserve (tool->control);

      gimp_image_flush (gimp_display_get_image (tool->display));
    }
}
コード例 #30
0
ファイル: gimpprogressdialog.c プロジェクト: Amerekanets/gimp
static void
gimp_progress_dialog_progress_end (GimpProgress *progress)
{
  GimpProgressDialog *dialog = GIMP_PROGRESS_DIALOG (progress);

  if (! dialog->box)
    return;

  if (GIMP_PROGRESS_BOX (dialog->box)->active)
    {
      gimp_progress_end (GIMP_PROGRESS (dialog->box));

      gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
                                         GTK_RESPONSE_CANCEL, FALSE);

      gtk_widget_hide (GTK_WIDGET (dialog));
    }
}