Exemplo n.º 1
0
/**
 * g_paste_clipboard_select_item:
 * @self: a #GPasteClipboard instance
 * @item: the item to select
 *
 * Put the value of the item into the #GPasteClipbaord and the intern GtkClipboard
 *
 * Returns:
 */
G_PASTE_VISIBLE void
g_paste_clipboard_select_item (GPasteClipboard  *self,
                               const GPasteItem *item)
{
    g_return_if_fail (G_PASTE_IS_CLIPBOARD (self));
    g_return_if_fail (G_PASTE_IS_ITEM (item));

    if (G_PASTE_IS_IMAGE_ITEM (item))
    {
        GPasteImageItem *image_item = G_PASTE_IMAGE_ITEM (item);
        const gchar *checksum = g_paste_image_item_get_checksum (image_item);

        if (g_strcmp0 (checksum, self->priv->image_checksum) != 0)
            _g_paste_clipboard_select_image (self,
                                             g_paste_image_item_get_image (image_item),
                                             checksum);
    }
    else
    {
        const gchar *text = g_paste_item_get_value (item);

        if (g_strcmp0 (text, self->priv->text) != 0)
        {
            if (G_PASTE_IS_URIS_ITEM (item))
                _g_paste_clipboard_select_uris (self, G_PASTE_URIS_ITEM (item));
            else /* if (G_PASTE_IS_TEXT_ITEM (item)) */
                g_paste_clipboard_select_text (self, text);
        }
    }
}
Exemplo n.º 2
0
static void
g_paste_image_item_set_size (GPasteItem *self)
{
    GPasteImageItemPrivate *priv = g_paste_image_item_get_instance_private (G_PASTE_IMAGE_ITEM (self));
    GdkPixbuf *image = priv->image;

    if (image)
    {
        if (!priv->additional_size)
        {
            priv->additional_size += strlen (priv->checksum) + 1 + gdk_pixbuf_get_byte_length (image);
            g_paste_item_add_size (self, priv->additional_size);
        }
    }
    else
    {
        g_paste_item_remove_size (self, priv->additional_size);
        priv->additional_size = 0;
    }
}