Esempio n. 1
0
static void
gimp_clipboard_send_buffer (GtkClipboard     *clipboard,
                            GtkSelectionData *selection_data,
                            guint             info,
                            Gimp             *gimp)
{
  GimpClipboard *gimp_clip = gimp_clipboard_get (gimp);
  GdkPixbuf     *pixbuf;

  gimp_set_busy (gimp);

  pixbuf = gimp_viewable_get_pixbuf (GIMP_VIEWABLE (gimp_clip->buffer),
                                     gimp_get_user_context (gimp),
                                     gimp_buffer_get_width (gimp_clip->buffer),
                                     gimp_buffer_get_height (gimp_clip->buffer));

  if (pixbuf)
    {
      if (gimp->be_verbose)
        g_printerr ("clipboard: sending pixbuf data as '%s'\n",
                    gimp_clip->target_entries[info].target);

      gtk_selection_data_set_pixbuf (selection_data, pixbuf);
    }
  else
    {
      g_warning ("%s: gimp_viewable_get_pixbuf() failed", G_STRFUNC);
    }

  gimp_unset_busy (gimp);
}
Esempio n. 2
0
static gboolean
windows_menu_display_query_tooltip (GtkWidget  *widget,
                                    gint        x,
                                    gint        y,
                                    gboolean    keyboard_mode,
                                    GtkTooltip *tooltip,
                                    GimpAction *action)
{
  GimpImage *image = GIMP_IMAGE (action->viewable);
  gchar     *text;
  gdouble    xres;
  gdouble    yres;
  gint       width;
  gint       height;

  text = gtk_widget_get_tooltip_text (widget);
  gtk_tooltip_set_text (tooltip, text);
  g_free (text);

  gimp_image_get_resolution (image, &xres, &yres);

  gimp_viewable_calc_preview_size (gimp_image_get_width  (image),
                                   gimp_image_get_height (image),
                                   GIMP_VIEW_SIZE_HUGE, GIMP_VIEW_SIZE_HUGE,
                                   FALSE, xres, yres,
                                   &width, &height, NULL);

  gtk_tooltip_set_icon (tooltip,
                        gimp_viewable_get_pixbuf (action->viewable,
                                                  action->context,
                                                  width, height));

  return TRUE;
}
Esempio n. 3
0
static void
gimp_view_renderer_real_render (GimpViewRenderer *renderer,
                                GtkWidget        *widget)
{
  GdkPixbuf   *pixbuf;
  GimpTempBuf *temp_buf;
  const gchar *icon_name;

  pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
                                     renderer->context,
                                     renderer->width,
                                     renderer->height);
  if (pixbuf)
    {
      gimp_view_renderer_render_pixbuf (renderer, widget, pixbuf);
      return;
    }

  temp_buf = gimp_viewable_get_preview (renderer->viewable,
                                        renderer->context,
                                        renderer->width,
                                        renderer->height);
  if (temp_buf)
    {
      gimp_view_renderer_render_temp_buf_simple (renderer, widget, temp_buf);
      return;
    }

  icon_name = gimp_viewable_get_icon_name (renderer->viewable);
  gimp_view_renderer_render_icon (renderer, widget, icon_name);
}
Esempio n. 4
0
static gboolean
gimp_display_shell_icon_update_idle (gpointer data)
{
  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data);
  GimpImage        *image = gimp_display_get_image (shell->display);
  GdkPixbuf        *icon  = NULL;

  shell->icon_idle_id = 0;

  if (image)
    {
      Gimp      *gimp = gimp_display_get_gimp (shell->display);
      GdkPixbuf *pixbuf;
      gint       width;
      gint       height;
      gint       scale_factor;
      gdouble    factor = ((gdouble) gimp_image_get_height (image) /
                           (gdouble) gimp_image_get_width  (image));

      if (factor >= 1)
        {
          height = MAX (shell->icon_size, 1);
          width  = MAX (((gdouble) shell->icon_size) / factor, 1);
        }
      else
        {
          height = MAX (((gdouble) shell->icon_size) * factor, 1);
          width  = MAX (shell->icon_size, 1);
        }

      scale_factor = gtk_widget_get_scale_factor (GTK_WIDGET (shell));
      width  *= scale_factor;
      height *= scale_factor;
      pixbuf = gimp_viewable_get_pixbuf (GIMP_VIEWABLE (image),
                                         gimp_get_user_context (gimp),
                                         width, height);

      icon = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
                             shell->icon_size * scale_factor,
                             shell->icon_size * scale_factor);

      memset (gdk_pixbuf_get_pixels (icon), 0,
              gdk_pixbuf_get_height (icon) *
              gdk_pixbuf_get_rowstride (icon));

      gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height,
                            icon,
                            0, shell->icon_size * scale_factor - height);

      pixbuf = gimp_widget_load_icon (GTK_WIDGET (shell), "gimp-wilber-outline",
                                      shell->icon_size_small);

      width  = gdk_pixbuf_get_width  (pixbuf);
      height = gdk_pixbuf_get_height (pixbuf);

      gdk_pixbuf_composite (pixbuf, icon,
                            shell->icon_size * scale_factor - width,
                            0, width, height,
                            shell->icon_size * scale_factor - width,
                            0.0, 1.0, 1.0,
                            GDK_INTERP_NEAREST, 255);
      g_object_unref (pixbuf);
    }

  g_object_set (shell, "icon", icon, NULL);

  if (icon)
    g_object_unref (icon);

  return FALSE;
}