static GimpProgress *
gimp_tool_progress_start (GimpProgress *progress,
                          const gchar  *message,
                          gboolean      cancelable)
{
  GimpTool         *tool = GIMP_TOOL (progress);
  GimpDisplayShell *shell;
  gint              x, y, w, h;

  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);

  gimp_display_shell_untransform_viewport (shell, &x, &y, &w, &h);

  tool->progress = gimp_canvas_progress_new (shell,
                                             GIMP_HANDLE_ANCHOR_CENTER,
                                             x + w / 2, y + h / 2);
  gimp_display_shell_add_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;

  return progress;
}
Пример #2
0
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);
    }
}
Пример #3
0
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);
    }
}
Пример #4
0
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;
}