Example #1
0
void wxClipboard::Clear()
{
    gtk_selection_clear_targets( m_clipboardWidget, GTKGetClipboardAtom() );

    if ( gdk_selection_owner_get(GTKGetClipboardAtom()) ==
            gtk_widget_get_window(m_clipboardWidget) )
    {
        wxClipboardSync sync(*this);

        // this will result in selection_clear_clip callback being called and
        // it will free our data
        SetSelectionOwner(false);
    }

    m_targetRequested = 0;
    m_formatSupported = false;
}
Example #2
0
static VALUE
gtkdrag_selection_clear_targets(VALUE self, VALUE widget, VALUE selection)
{
    gtk_selection_clear_targets(RVAL2WIDGET(widget), RVAL2ATOM(selection));
    return self;
}
Example #3
0
NS_IMETHODIMP
nsClipboard::SetData(nsITransferable *aTransferable,
                     nsIClipboardOwner *aOwner, PRInt32 aWhichClipboard)
{
    // See if we can short cut
    if ((aWhichClipboard == kGlobalClipboard &&
            aTransferable == mGlobalTransferable.get() &&
            aOwner == mGlobalOwner.get()) ||
            (aWhichClipboard == kSelectionClipboard &&
             aTransferable == mSelectionTransferable.get() &&
             aOwner == mSelectionOwner.get())) {
        return NS_OK;
    }

    // Clear out the clipboard in order to set the new data
    EmptyClipboard(aWhichClipboard);

    if (aWhichClipboard == kSelectionClipboard) {
        mSelectionOwner = aOwner;
        mSelectionTransferable = aTransferable;
    }
    else {
        mGlobalOwner = aOwner;
        mGlobalTransferable = aTransferable;
    }

    // Which selection are we about to claim, CLIPBOARD or PRIMARY?
    GdkAtom selectionAtom = GetSelectionAtom(aWhichClipboard);

    // Make ourselves the owner.  If we fail to, return.
    if (!gtk_selection_owner_set(mWidget, selectionAtom, GDK_CURRENT_TIME))
        return NS_ERROR_FAILURE;

    // Clear the old selection target list.
    gtk_selection_clear_targets(mWidget, selectionAtom);

    // Get the types of supported flavors
    nsresult rv;
    nsCOMPtr<nsISupportsArray> flavors;

    rv = aTransferable->FlavorsTransferableCanExport(getter_AddRefs(flavors));
    if (!flavors || NS_FAILED(rv))
        return NS_ERROR_FAILURE;

    // Add all the flavors to this widget's supported type.
    PRUint32 count;
    flavors->Count(&count);
    for (PRUint32 i=0; i < count; i++) {
        nsCOMPtr<nsISupports> tastesLike;
        flavors->GetElementAt(i, getter_AddRefs(tastesLike));
        nsCOMPtr<nsISupportsCString> flavor = do_QueryInterface(tastesLike);

        if (flavor) {
            nsXPIDLCString flavorStr;
            flavor->ToString(getter_Copies(flavorStr));

            // special case text/unicode since we can handle all of
            // the string types
            if (!strcmp(flavorStr, kUnicodeMime)) {
                AddTarget(gdk_atom_intern("UTF8_STRING", FALSE),
                          selectionAtom);
                AddTarget(gdk_atom_intern("COMPOUND_TEXT", FALSE),
                          selectionAtom);
                AddTarget(gdk_atom_intern("TEXT", FALSE), selectionAtom);
                AddTarget(GDK_SELECTION_TYPE_STRING, selectionAtom);
                // next loop iteration
                continue;
            }

            // Add this to our list of valid targets
            GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
            AddTarget(atom, selectionAtom);
        }
    }

    return NS_OK;
}