예제 #1
0
파일: file-utils.c 프로젝트: bklynate/gimp
gchar *
file_utils_uri_display_basename (const gchar *uri)
{
    gchar *basename = NULL;

    g_return_val_if_fail (uri != NULL, NULL);

    if (g_str_has_prefix (uri, "file:"))
    {
        gchar *filename = file_utils_filename_from_uri (uri);

        if (filename)
        {
            basename = g_filename_display_basename (filename);
            g_free (filename);
        }
    }
    else
    {
        gchar *name = file_utils_uri_display_name (uri);

        basename = strrchr (name, '/');
        if (basename)
            basename = g_strdup (basename + 1);

        g_free (name);
    }

    return basename ? basename : file_utils_uri_to_utf8_basename (uri);
}
예제 #2
0
static GimpImage *
file_open_dialog_open_image (GtkWidget           *open_dialog,
                             Gimp                *gimp,
                             const gchar         *uri,
                             GimpPlugInProcedure *load_proc)
{
  GimpImage         *image;
  GimpPDBStatusType  status;
  GError            *error = NULL;

  image = file_open_with_proc_and_display (gimp,
                                           gimp_get_user_context (gimp),
                                           GIMP_PROGRESS (open_dialog),
                                           uri, uri, FALSE,
                                           load_proc,
                                           &status, &error);

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

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

      g_free (filename);
    }

  return image;
}
예제 #3
0
static void
documents_open_image (GtkWidget     *editor,
                      GimpContext   *context,
                      GimpImagefile *imagefile)
{
  const gchar        *uri;
  GimpImage          *image;
  GimpPDBStatusType   status;
  GError             *error = NULL;

  uri = gimp_object_get_name (imagefile);

  image = file_open_with_display (context->gimp, context, NULL, uri, FALSE,
                                  &status, &error);

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

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

      g_free (filename);
    }
}
예제 #4
0
/*  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,
                             const gchar *filename,
                             gboolean     as_new)
{
    GError   *error   = NULL;
    gchar    *uri;
    gboolean  success = FALSE;

    g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
    g_return_val_if_fail (filename != NULL, FALSE);

    /* we accept URI or filename */
    uri = file_utils_any_to_uri (gimp, filename, &error);

    if (uri)
    {
        GimpImage         *image;
        GimpObject        *display = gimp_get_empty_display (gimp);
        GimpPDBStatusType  status;

        image = file_open_with_display (gimp,
                                        gimp_get_user_context (gimp),
                                        GIMP_PROGRESS (display),
                                        uri, as_new,
                                        &status, &error);

        if (image)
        {
            success = TRUE;

            g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY,
                                    uri, (GDestroyNotify) g_free);
        }
        else if (status != GIMP_PDB_CANCEL)
        {
            gchar *filename = file_utils_uri_display_name (uri);

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

            g_free (filename);
            g_free (uri);
        }
    }
    else
    {
        g_printerr ("conversion filename -> uri failed: %s\n",
                    error->message);
        g_clear_error (&error);
    }

    return success;
}
예제 #5
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);
    }
}
예제 #6
0
static void
gimp_display_shell_exported_handler (GimpImage        *image,
                                     const gchar      *uri,
                                     GimpDisplayShell *shell)
{
  GimpStatusbar *statusbar = gimp_display_shell_get_statusbar (shell);
  gchar         *filename  = file_utils_uri_display_name (uri);

  gimp_statusbar_push_temp (statusbar, GIMP_MESSAGE_INFO,
                            "document-save", _("Image exported to '%s'"),
                            filename);
  g_free (filename);
}
예제 #7
0
static gboolean
file_open_dialog_open_layers (GtkWidget           *open_dialog,
                              GimpImage           *image,
                              const gchar         *uri,
                              const gchar         *entered_filename,
                              GimpPlugInProcedure *load_proc)
{
  GList             *new_layers;
  GimpPDBStatusType  status;
  GError            *error = NULL;

  new_layers = file_open_layers (image->gimp,
                                 gimp_get_user_context (image->gimp),
                                 GIMP_PROGRESS (open_dialog),
                                 image, FALSE,
                                 uri, GIMP_RUN_INTERACTIVE, load_proc,
                                 &status, &error);

  if (new_layers)
    {
      gimp_image_add_layers (image, new_layers,
                             GIMP_IMAGE_ACTIVE_PARENT, -1,
                             0, 0,
                             gimp_image_get_width (image),
                             gimp_image_get_height (image),
                             _("Open layers"));

      g_list_free (new_layers);

      return TRUE;
    }
  else if (status != GIMP_PDB_CANCEL)
    {
      gchar *filename = file_utils_uri_display_name (uri);

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

      g_free (filename);
    }

  return FALSE;
}
예제 #8
0
void
file_last_opened_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_num_children (gimp->documents);

  if (value >= num_entries)
    return;

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

  if (imagefile)
    {
      GimpImage         *image;
      GimpPDBStatusType  status;
      GError            *error = NULL;

      image = file_open_with_display (gimp, action_data_get_context (data),
                                      NULL,
                                      GIMP_OBJECT (imagefile)->name, FALSE,
                                      &status, &error);

      if (! image && status != GIMP_PDB_CANCEL)
        {
          gchar *filename =
            file_utils_uri_display_name (GIMP_OBJECT (imagefile)->name);

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

          g_free (filename);
        }
    }
}
예제 #9
0
static void
gimp_image_prop_view_label_set_filename (GtkWidget *label,
                                         GimpImage *image)
{
  const gchar *uri = gimp_image_get_any_uri (image);

  if (uri)
    {
      gchar *name = file_utils_uri_display_name (uri);

      gtk_label_set_text (GTK_LABEL (label), name);
      g_free (name);
    }
  else
    {
      gtk_label_set_text (GTK_LABEL (label), NULL);
      gimp_help_set_help_data (gtk_widget_get_parent (label), NULL, NULL);
    }
}
예제 #10
0
static void
gimp_toolbox_drop_uri_list (GtkWidget *widget,
                            gint       x,
                            gint       y,
                            GList     *uri_list,
                            gpointer   data)
{
  GimpContext *context = GIMP_CONTEXT (data);
  GList       *list;

  if (context->gimp->busy)
    return;

  for (list = uri_list; list; list = g_list_next (list))
    {
      const gchar       *uri   = list->data;
      GimpImage         *image;
      GimpPDBStatusType  status;
      GError            *error = NULL;

      image = file_open_with_display (context->gimp, context, NULL,
                                      uri, FALSE, &status, &error);

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

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

          g_clear_error (&error);
          g_free (filename);
        }
    }
}
예제 #11
0
static void
gimp_display_shell_drop_uri_list (GtkWidget *widget,
                                  gint       x,
                                  gint       y,
                                  GList     *uri_list,
                                  gpointer   data)
{
  GimpDisplayShell *shell   = GIMP_DISPLAY_SHELL (data);
  GimpImage        *image;
  GimpContext      *context;
  GList            *list;
  gboolean          open_as_layers;

  /* If the app is already being torn down, shell->display might be NULL here.
   * Play it safe. */
  if (! shell->display)
    {
      return;
    }

  image = shell->display->image;
  context = gimp_get_user_context (shell->display->gimp);

  GIMP_LOG (DND, NULL);

  open_as_layers = (shell->display->image != NULL);

  for (list = uri_list; list; list = g_list_next (list))
    {
      const gchar       *uri   = list->data;
      GimpPDBStatusType  status;
      GError            *error = NULL;
      gboolean           warn  = FALSE;

      if (! shell->display)
        {
          /* It seems as if GIMP is being torn down for quitting. Bail out. */
          return;
        }

      if (open_as_layers)
        {
          GList *new_layers;

          new_layers = file_open_layers (shell->display->gimp, context,
                                         GIMP_PROGRESS (shell->display),
                                         image, FALSE,
                                         uri, GIMP_RUN_INTERACTIVE, NULL,
                                         &status, &error);

          if (new_layers)
            {
              gint x, y;
              gint width, height;

              gimp_display_shell_untransform_viewport (shell, &x, &y,
                                                       &width, &height);

              gimp_image_add_layers (image, new_layers, -1,
                                     x, y, width, height,
                                     _("Drop layers"));

              g_list_free (new_layers);
            }
          else if (status != GIMP_PDB_CANCEL)
            {
              warn = TRUE;
            }
        }
      else if (shell->display->image)
        {
          /*  open any subsequent images in a new display  */
          GimpImage *new_image;

          new_image = file_open_with_display (shell->display->gimp, context,
                                              NULL,
                                              uri, FALSE,
                                              &status, &error);

          if (! new_image && status != GIMP_PDB_CANCEL)
            warn = TRUE;
        }
      else
        {
          /*  open the first image in the empty display  */
          image = file_open_with_display (shell->display->gimp, context,
                                          GIMP_PROGRESS (shell->display),
                                          uri, FALSE,
                                          &status, &error);

          if (! image && status != GIMP_PDB_CANCEL)
            warn = TRUE;
        }

      /* Something above might have run a few rounds of the main loop. Check
       * that shell->display is still there, otherwise ignore this as the app
       * is being torn down for quitting. */
      if (warn && shell->display)
        {
          gchar *filename = file_utils_uri_display_name (uri);

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

          g_clear_error (&error);
          g_free (filename);
        }
    }

  if (image)
    gimp_display_shell_dnd_flush (shell, image);
}
예제 #12
0
파일: file-commands.c 프로젝트: 1ynx/gimp
void
file_revert_cmd_callback (GtkAction *action,
                          gpointer   data)
{
  GimpDisplay *display;
  GimpImage   *image;
  GtkWidget   *dialog;
  const gchar *uri;
  return_if_no_display (display, data);

  image = gimp_display_get_image (display);

  uri = gimp_image_get_uri (image);

  if (! uri)
    uri = gimp_image_get_imported_uri (image);

  dialog = g_object_get_data (G_OBJECT (image), REVERT_DATA_KEY);

  if (! uri)
    {
      gimp_message_literal (image->gimp,
			    G_OBJECT (display), GIMP_MESSAGE_ERROR,
			    _("Revert failed. "
			      "No file name associated with this image."));
    }
  else if (dialog)
    {
      gtk_window_present (GTK_WINDOW (dialog));
    }
  else
    {
      gchar *filename;

      dialog =
        gimp_message_dialog_new (_("Revert Image"), GTK_STOCK_REVERT_TO_SAVED,
                                 GTK_WIDGET (gimp_display_get_shell (display)),
                                 0,
                                 gimp_standard_help_func, GIMP_HELP_FILE_REVERT,

                                 GTK_STOCK_CANCEL,          GTK_RESPONSE_CANCEL,
                                 GTK_STOCK_REVERT_TO_SAVED, GTK_RESPONSE_OK,

                                 NULL);

      gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                               GTK_RESPONSE_OK,
                                               GTK_RESPONSE_CANCEL,
                                               -1);

      g_signal_connect_object (display, "disconnect",
                               G_CALLBACK (gtk_widget_destroy),
                               dialog, G_CONNECT_SWAPPED);

      g_signal_connect (dialog, "response",
                        G_CALLBACK (file_revert_confirm_response),
                        display);

      filename = file_utils_uri_display_name (uri);

      gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                         _("Revert '%s' to '%s'?"),
                                         gimp_image_get_display_name (image),
                                         filename);
      g_free (filename);

      gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                 _("By reverting the image to the state saved "
                                   "on disk, you will lose all changes, "
                                   "including all undo information."));

      g_object_set_data (G_OBJECT (image), REVERT_DATA_KEY, dialog);

      gtk_widget_show (dialog);
    }
}
예제 #13
0
void
file_save_cmd_callback (GtkAction *action,
                        gint       value,
                        gpointer   data)
{
  GimpDisplay  *display;
  GimpImage    *image;
  GtkWidget    *widget;
  GimpSaveMode  save_mode;
  gboolean      saved = FALSE;
  return_if_no_display (display, data);
  return_if_no_widget (widget, data);

  image = display->image;

  save_mode = (GimpSaveMode) value;

  if (! gimp_image_get_active_drawable (image))
    return;

  switch (save_mode)
    {
    case GIMP_SAVE_MODE_SAVE:
    case GIMP_SAVE_MODE_SAVE_AND_CLOSE:
      /*  Only save if the image has been modified  */
      if (image->dirty ||
          ! GIMP_GUI_CONFIG (image->gimp->config)->trust_dirty_flag)
        {
          const gchar         *uri;
          GimpPlugInProcedure *save_proc = NULL;

          uri       = gimp_object_get_name (GIMP_OBJECT (image));
          save_proc = gimp_image_get_save_proc (image);

          if (uri && ! save_proc)
            save_proc =
              file_procedure_find (image->gimp->plug_in_manager->save_procs,
                                   uri, NULL);

          if (uri && save_proc)
            {
              GimpPDBStatusType  status;
              GError            *error = NULL;
              GList             *list;

              for (list = gimp_action_groups_from_name ("file");
                   list;
                   list = g_list_next (list))
                {
                  gimp_action_group_set_action_sensitive (list->data,
                                                          "file-quit",
                                                          FALSE);
                }

              status = file_save (image, action_data_get_context (data),
                                  GIMP_PROGRESS (display),
                                  uri, save_proc,
                                  GIMP_RUN_WITH_LAST_VALS, FALSE, &error);

              switch (status)
                {
                case GIMP_PDB_SUCCESS:
                  saved = TRUE;
                  break;

                case GIMP_PDB_CANCEL:
                  gimp_message (image->gimp, G_OBJECT (display),
                                GIMP_MESSAGE_INFO,
                                _("Saving canceled"));
                  break;

                default:
                  {
                    gchar *filename = file_utils_uri_display_name (uri);

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

              for (list = gimp_action_groups_from_name ("file");
                   list;
                   list = g_list_next (list))
                {
                  gimp_action_group_set_action_sensitive (list->data,
                                                          "file-quit",
                                                          TRUE);
                }

              break;
            }

          /* fall thru */
        }
      else
        {
          saved = TRUE;
          break;
        }

    case GIMP_SAVE_MODE_SAVE_AS:
      file_save_dialog_show (display->image, widget,
                             _("Save Image"), FALSE,
                             save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE);
      break;

    case GIMP_SAVE_MODE_SAVE_A_COPY:
      file_save_dialog_show (display->image, widget,
                             _("Save a Copy of the Image"), TRUE,
                             FALSE);
      break;
    }

  if (save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE &&
      saved && ! display->image->dirty)
    {
      gimp_display_delete (display);
    }
}
예제 #14
0
static void
gimp_display_shell_format_title (GimpDisplayShell *shell,
                                 gchar            *title,
                                 gint              title_len,
                                 const gchar      *format)
{
  Gimp      *gimp;
  GimpImage *image;
  gint       num, denom;
  gint       i = 0;

  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));

  image = shell->display->image;
  gimp  = image->gimp;

  gimp_zoom_model_get_fraction (shell->zoom, &num, &denom);

  while (i < title_len && *format)
    {
      switch (*format)
        {
        case '%':
          format++;
          switch (*format)
            {
            case 0:
              /* format string ends within %-sequence, print literal '%' */

            case '%':
              title[i++] = '%';
              break;

            case 'f': /* pruned filename */
              {
                const gchar *uri = gimp_image_get_uri (image);
                gchar       *basename;

                basename = file_utils_uri_display_basename (uri);

                i += print (title, title_len, i, "%s", basename);

                g_free (basename);
              }
              break;

            case 'F': /* full filename */
              {
                gchar *filename;
                const gchar *uri = gimp_image_get_uri (image);

                filename = file_utils_uri_display_name (uri);

                i += print (title, title_len, i, "%s", filename);

                g_free (filename);
              }
              break;

            case 'p': /* PDB id */
              i += print (title, title_len, i, "%d", gimp_image_get_ID (image));
              break;

            case 'i': /* instance */
              i += print (title, title_len, i, "%d", shell->display->instance);
              break;

            case 't': /* type */
              {
                const gchar *image_type_str = NULL;
                gboolean     empty          = gimp_image_is_empty (image);

                switch (gimp_image_base_type (image))
                  {
                  case GIMP_RGB:
                    image_type_str = empty ? _("RGB-empty") : _("RGB");
                    break;
                  case GIMP_GRAY:
                    image_type_str = empty ? _("grayscale-empty") : _("grayscale");
                    break;
                  case GIMP_INDEXED:
                    image_type_str = empty ? _("indexed-empty") : _("indexed");
                    break;
                  default:
                    g_assert_not_reached ();
                    break;
                  }

                i += print (title, title_len, i, "%s", image_type_str);
              }
              break;

            case 's': /* user source zoom factor */
              i += print (title, title_len, i, "%d", denom);
              break;

            case 'd': /* user destination zoom factor */
              i += print (title, title_len, i, "%d", num);
              break;

            case 'z': /* user zoom factor (percentage) */
              {
                gdouble  scale = gimp_zoom_model_get_factor (shell->zoom);

                i += print (title, title_len, i,
                            scale >= 0.15 ? "%.0f" : "%.2f", 100.0 * scale);
              }
              break;

            case 'D': /* dirty flag */
              if (format[1] == 0)
                {
                  /* format string ends within %D-sequence, print literal '%D' */
                  i += print (title, title_len, i, "%%D");
                  break;
                }
              if (image->dirty)
                title[i++] = format[1];
              format++;
              break;

            case 'C': /* clean flag */
              if (format[1] == 0)
                {
                  /* format string ends within %C-sequence, print literal '%C' */
                  i += print (title, title_len, i, "%%C");
                  break;
                }
              if (! image->dirty)
                title[i++] = format[1];
              format++;
              break;

            case 'B': /* dirty flag (long) */
              if (image->dirty)
                i += print (title, title_len, i, "%s", _("(modified)"));
              break;

            case 'A': /* clean flag (long) */
              if (! image->dirty)
                i += print (title, title_len, i, "%s", _("(clean)"));
              break;

            case 'm': /* memory used by image */
              {
                GimpObject *object = GIMP_OBJECT (image);
                gchar      *str;

                str = gimp_memsize_to_string (gimp_object_get_memsize (object,
                                                                       NULL));

                i += print (title, title_len, i, "%s", str);

                g_free (str);
              }
              break;

            case 'l': /* number of layers */
              i += print (title, title_len, i, "%d",
                          gimp_container_num_children (image->layers));
              break;

            case 'L': /* number of layers (long) */
              {
                gint num = gimp_container_num_children (image->layers);

                i += print (title, title_len, i,
                            ngettext ("%d layer", "%d layers", num), num);
              }
              break;

            case 'n': /* active drawable name */
              {
                GimpDrawable *drawable = gimp_image_get_active_drawable (image);

                if (drawable)
                  i += print (title, title_len, i, "%s",
                              gimp_object_get_name (GIMP_OBJECT (drawable)));
                else
                  i += print (title, title_len, i, "%s", _("(none)"));
              }
              break;

            case 'P': /* active drawable PDB id */
              {
                GimpDrawable *drawable = gimp_image_get_active_drawable (image);

                if (drawable)
                  i += print (title, title_len, i, "%d",
                              gimp_item_get_ID (GIMP_ITEM (drawable)));
                else
                  i += print (title, title_len, i, "%s", _("(none)"));
              }
              break;

            case 'W': /* width in real-world units */
              if (shell->unit != GIMP_UNIT_PIXEL)
                {
                  gchar unit_format[8];

                  g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
                              _gimp_unit_get_digits (gimp, shell->unit) + 1);
                  i += print (title, title_len, i, unit_format,
                              (image->width *
                               _gimp_unit_get_factor (gimp, shell->unit) /
                               image->xresolution));
                  break;
                }
              /* else fallthru */
            case 'w': /* width in pixels */
              i += print (title, title_len, i, "%d", image->width);
              break;

            case 'H': /* height in real-world units */
              if (shell->unit != GIMP_UNIT_PIXEL)
                {
                  gchar unit_format[8];

                  g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
                              _gimp_unit_get_digits (gimp, shell->unit) + 1);
                  i += print (title, title_len, i, unit_format,
                              (image->height *
                               _gimp_unit_get_factor (gimp, shell->unit) /
                               image->yresolution));
                  break;
                }
              /* else fallthru */
            case 'h': /* height in pixels */
              i += print (title, title_len, i, "%d", image->height);
              break;

            case 'u': /* unit symbol */
              i += print (title, title_len, i, "%s",
                          _gimp_unit_get_symbol (gimp, shell->unit));
              break;

            case 'U': /* unit abbreviation */
              i += print (title, title_len, i, "%s",
                          _gimp_unit_get_abbreviation (gimp, shell->unit));
              break;

              /* Other cool things to be added:
               * %r = xresolution
               * %R = yresolution
               * %ø = image's fractal dimension
               * %þ = the answer to everything
               */

            default:
              /* format string contains unknown %-sequence, print it literally */
              i += print (title, title_len, i, "%%%c", *format);
              break;
            }
          break;

        default:
          title[i++] = *format;
          break;
        }

      format++;
    }

  title[MIN (i, title_len - 1)] = '\0';
}