gtk.gdk.DragContext — an object containing the drag and drop context data
class gtk.gdk.DragContext( |
|
A gtk.gdk.DragContext
holds information about a drag in progress. It is used for both source and
destination. A gtk.gdk.DragContext
can be created using the gtk.gdk.DragContext()
constructor but since there is no way to set its attributes the new object
is not much use. Useful gtk.gdk.DragContext
objects are created as a result of the gtk.gdk.Window.drag_begin
()
or the gtk.Widget.drag_begin
()
methods.
gtk.gdk.DragContext()
Returns : | a new gtk.gdk.DragContext |
Creates a new gtk.gdk.DragContext
object.
def drag_status(action
, time
)
| a drag action that will be taken when a drop happens |
| the timestamp for this action |
The drag_status
() method sets the
specified action
to be taken when a drop happens. The
value of action
is one of:
| |
| Copy the data. |
| Move the data, i.e. first copy it, then delete it from the source using the DELETE target of the X selection protocol. |
| Add a link to the data. Note that this is only useful if source and destination agree on what it means. |
| Special action which tells the source that the destination will do something that the source doesn't understand. |
| Ask the user what to do with the data. |
The time the action occurred is specified by
time
. This method is called by the drag destination
in response to drag_motion
()
called by the drag source.
def drop_reply(ok
, time
)
| if True the drop is accepted
by the destination |
| the timestamp |
The drop_reply
() method determines if
the drop is accepted or rejected according to the value specified by
ok
. If ok
is
True
the drop is accepted. time
specifies the time that the drop reply occurred. This method is called by
the drag destination when a drop is initiated by the drag source.
def drop_finish(success
, time
)
| if True the data was received |
| the time of the finish |
The drop_finish
() method ends a drag
operation and indicates if the drop was successful by setting the value of
success
. time
indicates the
time of the drop finish. This method is called by the drag
destination.
def drag_get_selection()
Returns : | the selection atom |
The drag_get_selection
() method returns
the selection atom for the current source window.
def drag_find_window(drag_window
, x_root
, y_root
)
| a gtk.gdk.Window |
| the x position of the pointer in root coordinates. |
| the y position of the pointer in root coordinates. |
Returns : | a 2-tuple containing the drag destination gtk.gdk.Window and
the drag protocol |
The drag_find_window
() method returns a
2-tuple containing the drag destination gtk.gdk.Window
and
the drag protocol being used. The drag protocol is one of:
| The Motif DND protocol. |
| The Xdnd protocol. |
| An extension to the Xdnd protocol for unclaimed root window drops. |
| no protocol. |
| The simple WM_DROPFILES protocol. |
| The complex OLE2 DND protocol (not implemented). |
| Intra-application DND. |
drag_window
is a gtk.gdk.Window
and
x_root
and y_root
specify the
location of the mouse pointer in the root window.
def drag_find_window_for_screen(drag_window
, screen
, x_root
, y_root
)
| a gtk.gdk.Window |
| a gtk.gdk.Screen |
| the x position of the pointer in root coordinates. |
| the y position of the pointer in root coordinates. |
Returns : | a 2-tuple containing the drag destination gtk.gdk.Window and
the drag protocol |
This method is available in PyGTK 2.2 and above.
The drag_find_window_for_screen
()
method returns a 2-tuple containing the drag destination gtk.gdk.Window
and
the drag protocol being used. The drag protocol is one of:
| The Motif DND protocol. |
| The Xdnd protocol. |
| An extension to the Xdnd protocol for unclaimed root window drops. |
| no protocol. |
| The simple WM_DROPFILES protocol. |
| The complex OLE2 DND protocol (not implemented). |
| Intra-application DND. |
drag_window
is a gtk.gdk.Window
and
x_root
and y_root
specify the
location of the mouse pointer in the root window.
def drag_motion(dest_window
, protocol
, x_root
, y_root
, suggested_action
, possible_actions
, time
)
| the destination gtk.gdk.Window the
drag is moving over |
| the drag protocol in use |
| the x root coordinate of the mouse pointer |
| the y root coordinate of the mouse pointer |
| the suggest drag action |
| the possible drag actions |
| the timestamp of the drag motion |
Returns : | True if there is a drag destination window and the drag has paused or a drop has occurred. |
The drag_motion
() method updates the
drag context when the pointer moves or the set of actions changes. This
method is called by the drag source. dest_window
specifies the drag destination gtk.gdk.Window
;
protocol
specifies the drag protocol being used (see
the drag_find_window
()
method for details); x_root
and
y_root
specify the root window coordinates of the
mouse pointer; suggested_action
specifies the
suggested drag action (see the drag_status
()
method for more detail); possible_actions specifies the possible drag
actions for the drag (see the drag_status
()
method for more detail); and, time
specifies the
timestamp of the drag motion.
def drag_drop(time
)
| the timestamp of the drag drop. |
The drag_drop
() method initiates a drop
on the current drag destination at the time specified by
time
. This method is called by the drag
source.
def drag_abort(time
)
| the time of the drag abort operation |
The drag_abort
() method aborts the
current drag operation at the specified time
. No drop
operation is initiated. This method is called by the drag source.
def finish(success
, del_
, time
)
| if True the drop was
completed |
| if True the drag source
should delete the source data |
| the time of the drag finish operation. |
The finish
() method informs the drag
source that the drop is finished, and that the data of the drag will no
longer be required. If success
is
True
the drag drop completed successfully; if
del_
is True
the source data
should be deleted; time
is the timestamp of the
finish operation. This method is called by the drag destination.
def get_source_widget()
Returns : | the source gtk.Widget if the
drag is within the same application or None
otherwise. |
The get_source_widget
() method returns
the source gtk.Widget
if the
drag is within the application; otherwise None
is
returned.
def set_icon_widget(widget
, hot_x
, hot_y
)
| a toplevel window to use as an icon. |
| the X offset within
widget of the hotspot. |
| the Y offset within
widget of the hotspot. |
The set_icon_widget
() method changes
the icon for a drag source to the specified widget
with its hot spot at the offset specified by hot_x
and hot_y
. PyGTK
will not destroy
the icon, so if you don't want it to persist, you should connect to the
"drag_end" signal and destroy it yourself.
def set_icon_pixmap(colormap
, pixmap
, mask
, hot_x
, hot_y
)
| the colormap of the icon |
| the gtk.gdk.Pixmap image
data for the icon |
| the gtk.gdk.Pixmap
transparency mask for the icon |
| the X offset within
pixmap of the hotspot. |
| the Y offset within
pixmap of the hotspot. |
The set_icon_pixmap
() method sets
pixmap
as the icon for the drag.
mask
is a bitmap mask for
pixmap
and hot_x
and
hot_y
specify the offset of the hot spot in
pixmap
. In general, gtk.gdk.DragContext.set_icon_pixbuf()
will be more convenient to use.
def set_icon_pixbuf(pixbuf
, hot_x
, hot_y
)
| the gtk.gdk.Pixbuf to
use as the drag icon. |
| the X offset within
pixbuf of the hotspot. |
| the Y offset within
pixbuf of the hotspot. |
The set_icon_pixbuf
() method sets
pixbuf
as the icon for the drag.
hot_x
and hot_y
specify the
offset of the hot spot within pixbuf
.
def set_icon_stock(stock_id
, hot_x
, hot_y
)
| the ID of the stock icon to use for the drag. |
| the X offset within the icon of the hotspot. |
| the Y offset within the icon of the hotspot. |
The set_icon_stock
() method sets the
the icon for a given drag from a stock ID specified by
stock_id
. hot_x
and
hot_y
specify the offset of the hot spot within the
stock icon.
def set_icon_name(icon_name
, hot_x
, hot_y
)
| the name of the icon to use for the drag. |
| the X offset within the icon of the hotspot. |
| the Y offset within the icon of the hotspot. |
This method is available in PyGTK 2.10 and above.
The set_icon_name
() method sets the the
icon for a given drag from the named themed icon specified by
icon_name
. hot_x
and
hot_y
specify the offset of the hot spot within the
stock icon. See the docs for gtk.IconTheme
for
more information. Note that the size of the icon depends on the icon theme
(the icon is loaded at the symbolic size
gtk.ICON_SIZE_DND
), thus hot_x
and
hot_y
have to be used with care.
def set_icon_default()
The set_icon_default
() method sets the
icon for the drag to the default icon.
def drag_drop_succeeded()
Returns : | True if the drop was
successful. |
The drag_drop_succeeded
() method
returns True
if the dropped data has been successfully
transferred. This method is intended to be used while handling a
gtk.gdk.DROP_FINISHED
event, its return value is
meaningless at other times.