mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
gdk: Remove gdk_selection_convert()
It's not used anymore.
This commit is contained in:
parent
ca5f859dc8
commit
54f9aef0d4
@ -425,10 +425,6 @@ GDK_SELECTION_TYPE_INTEGER
|
||||
GDK_SELECTION_TYPE_PIXMAP
|
||||
GDK_SELECTION_TYPE_WINDOW
|
||||
GDK_SELECTION_TYPE_STRING
|
||||
gdk_selection_convert
|
||||
gdk_selection_property_get
|
||||
gdk_selection_send_notify
|
||||
gdk_selection_send_notify_for_display
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
@ -763,7 +759,6 @@ GdkEventCrossing
|
||||
GdkEventFocus
|
||||
GdkEventConfigure
|
||||
GdkEventProperty
|
||||
GdkEventSelection
|
||||
GdkEventDND
|
||||
GdkEventProximity
|
||||
GdkEventWindowState
|
||||
|
@ -5185,7 +5185,6 @@ gtk_css_section_get_type
|
||||
<FILE>gtkselection</FILE>
|
||||
<TITLE>Selections</TITLE>
|
||||
GtkSelectionData
|
||||
gtk_selection_convert
|
||||
gtk_selection_data_set
|
||||
gtk_selection_data_set_text
|
||||
gtk_selection_data_get_text
|
||||
@ -5212,12 +5211,10 @@ gtk_selection_data_get_target
|
||||
gtk_targets_include_image
|
||||
gtk_targets_include_text
|
||||
gtk_targets_include_uri
|
||||
gtk_selection_remove_all
|
||||
gtk_selection_data_copy
|
||||
gtk_selection_data_free
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_SELECTION_DATA
|
||||
GTK_TYPE_TARGET_LIST
|
||||
<SUBSECTION Private>
|
||||
gtk_selection_data_get_type
|
||||
</SECTION>
|
||||
|
@ -573,9 +573,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
|
||||
display_class->notify_startup_complete = gdk_broadway_display_notify_startup_complete;
|
||||
display_class->create_window_impl = _gdk_broadway_display_create_window_impl;
|
||||
display_class->get_keymap = _gdk_broadway_display_get_keymap;
|
||||
display_class->send_selection_notify = _gdk_broadway_display_send_selection_notify;
|
||||
display_class->get_selection_property = _gdk_broadway_display_get_selection_property;
|
||||
display_class->convert_selection = _gdk_broadway_display_convert_selection;
|
||||
display_class->text_property_to_utf8_list = _gdk_broadway_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = _gdk_broadway_display_utf8_to_string_target;
|
||||
|
||||
|
@ -123,22 +123,6 @@ void _gdk_broadway_display_create_window_impl (GdkDisplay *display,
|
||||
GdkWindow *real_parent,
|
||||
GdkEventMask event_mask,
|
||||
GdkWindowAttr *attributes);
|
||||
gint _gdk_broadway_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format);
|
||||
void _gdk_broadway_display_send_selection_notify (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time);
|
||||
void _gdk_broadway_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time);
|
||||
gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
gint format,
|
||||
|
@ -33,49 +33,6 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void
|
||||
_gdk_broadway_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
g_warning ("convert_selection not implemented");
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_broadway_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
if (ret_type)
|
||||
*ret_type = NULL;
|
||||
if (ret_format)
|
||||
*ret_format = 0;
|
||||
if (data)
|
||||
*data = NULL;
|
||||
|
||||
g_warning ("get_selection_property not implemented");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_broadway_display_send_selection_notify (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
g_warning ("send_selection_notify not implemented");
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
make_list (const gchar *text,
|
||||
gint length,
|
||||
|
@ -167,23 +167,6 @@ struct _GdkDisplayClass
|
||||
|
||||
GdkKeymap * (*get_keymap) (GdkDisplay *display);
|
||||
|
||||
void (*send_selection_notify) (GdkDisplay *dispay,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time);
|
||||
gint (*get_selection_property) (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *type,
|
||||
gint *format);
|
||||
void (*convert_selection) (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time);
|
||||
|
||||
gint (*text_property_to_utf8_list) (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
gint format,
|
||||
|
14
gdk/gdkdnd.c
14
gdk/gdkdnd.c
@ -1032,7 +1032,6 @@ gboolean
|
||||
gdk_drag_context_handle_dest_event (GdkEvent *event)
|
||||
{
|
||||
GdkDragContext *context = NULL;
|
||||
GList *l;
|
||||
|
||||
switch ((guint) event->type)
|
||||
{
|
||||
@ -1040,19 +1039,6 @@ gdk_drag_context_handle_dest_event (GdkEvent *event)
|
||||
case GDK_DROP_START:
|
||||
context = event->dnd.context;
|
||||
break;
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
for (l = contexts; l; l = l->next)
|
||||
{
|
||||
GdkDragContext *c = l->data;
|
||||
|
||||
if (!c->is_source &&
|
||||
event->selection.selection == gdk_drag_get_selection (c))
|
||||
{
|
||||
context = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -587,12 +587,6 @@ gdk_event_copy (const GdkEvent *event)
|
||||
sizeof (gdouble) * gdk_device_get_n_axes (event->motion.device));
|
||||
break;
|
||||
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
new_event->selection.requestor = event->selection.requestor;
|
||||
if (new_event->selection.requestor)
|
||||
g_object_ref (new_event->selection.requestor);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -673,11 +667,6 @@ gdk_event_free (GdkEvent *event)
|
||||
g_free (event->motion.axes);
|
||||
break;
|
||||
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
if (event->selection.requestor)
|
||||
g_object_unref (event->selection.requestor);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -750,8 +739,6 @@ gdk_event_get_time (const GdkEvent *event)
|
||||
return event->crossing.time;
|
||||
case GDK_PROPERTY_NOTIFY:
|
||||
return event->property.time;
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
return event->selection.time;
|
||||
case GDK_PROXIMITY_IN:
|
||||
case GDK_PROXIMITY_OUT:
|
||||
return event->proximity.time;
|
||||
@ -846,7 +833,6 @@ gdk_event_get_state (const GdkEvent *event,
|
||||
case GDK_CLIENT_EVENT:
|
||||
case GDK_CONFIGURE:
|
||||
case GDK_FOCUS_CHANGE:
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
case GDK_PROXIMITY_IN:
|
||||
case GDK_PROXIMITY_OUT:
|
||||
case GDK_DAMAGE:
|
||||
@ -2698,72 +2684,6 @@ gdk_event_get_property (const GdkEvent *event,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_selection:
|
||||
* @event: a #GdkEvent
|
||||
* @selection: (out):
|
||||
*
|
||||
* Returns: %TRUE on success, otherwise %FALSE
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_selection (const GdkEvent *event,
|
||||
GdkAtom *selection)
|
||||
{
|
||||
if (!event)
|
||||
return FALSE;
|
||||
|
||||
if (event->type == GDK_SELECTION_NOTIFY)
|
||||
{
|
||||
*selection = event->selection.selection;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_selection_property:
|
||||
* @event: a #GdkEvent
|
||||
* @property: (out) (optional):
|
||||
* @target: (out) (optional):
|
||||
* @requestor: (out) (optional) (transfer none):
|
||||
*
|
||||
* Returns: %TRUE on success, otherwise %FALSE
|
||||
**/
|
||||
gboolean
|
||||
gdk_event_get_selection_property (const GdkEvent *event,
|
||||
GdkAtom *property,
|
||||
GdkAtom *target,
|
||||
GdkWindow **requestor)
|
||||
{
|
||||
if (!event)
|
||||
return FALSE;
|
||||
|
||||
if (event->type == GDK_SELECTION_NOTIFY)
|
||||
{
|
||||
if (property)
|
||||
*property = event->selection.property;
|
||||
if (target)
|
||||
*target = event->selection.target;
|
||||
if (requestor)
|
||||
*requestor = event->selection.requestor;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_event_set_selection (GdkEvent *event,
|
||||
GdkWindow *window,
|
||||
GdkAtom selection,
|
||||
guint32 time)
|
||||
{
|
||||
event->selection.window = g_object_ref (window);
|
||||
event->selection.selection = selection;
|
||||
event->selection.time = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_axes:
|
||||
* @event: a #GdkEvent
|
||||
|
@ -132,7 +132,6 @@ typedef struct _GdkEventFocus GdkEventFocus;
|
||||
typedef struct _GdkEventCrossing GdkEventCrossing;
|
||||
typedef struct _GdkEventConfigure GdkEventConfigure;
|
||||
typedef struct _GdkEventProperty GdkEventProperty;
|
||||
typedef struct _GdkEventSelection GdkEventSelection;
|
||||
typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
|
||||
typedef struct _GdkEventProximity GdkEventProximity;
|
||||
typedef struct _GdkEventDND GdkEventDND;
|
||||
@ -233,9 +232,6 @@ typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
|
||||
* @GDK_MAP: the window has been mapped.
|
||||
* @GDK_UNMAP: the window has been unmapped.
|
||||
* @GDK_PROPERTY_NOTIFY: a property on the window has been changed or deleted.
|
||||
* @GDK_SELECTION_CLEAR: the application has lost ownership of a selection.
|
||||
* @GDK_SELECTION_REQUEST: another application has requested a selection.
|
||||
* @GDK_SELECTION_NOTIFY: a selection has been received.
|
||||
* @GDK_PROXIMITY_IN: an input device has moved into contact with a sensing
|
||||
* surface (e.g. a touchscreen or graphics tablet).
|
||||
* @GDK_PROXIMITY_OUT: an input device has moved out of contact with a sensing
|
||||
@ -304,7 +300,6 @@ typedef enum
|
||||
GDK_MAP = 14,
|
||||
GDK_UNMAP = 15,
|
||||
GDK_PROPERTY_NOTIFY = 16,
|
||||
GDK_SELECTION_NOTIFY = 19,
|
||||
GDK_PROXIMITY_IN = 20,
|
||||
GDK_PROXIMITY_OUT = 21,
|
||||
GDK_DRAG_ENTER = 22,
|
||||
@ -715,19 +710,6 @@ gboolean gdk_event_get_property (const GdkEvent *event,
|
||||
GdkAtom *property,
|
||||
GdkPropertyState *state);
|
||||
GDK_AVAILABLE_IN_3_92
|
||||
gboolean gdk_event_get_selection (const GdkEvent *event,
|
||||
GdkAtom *selection);
|
||||
GDK_AVAILABLE_IN_3_92
|
||||
gboolean gdk_event_get_selection_property (const GdkEvent *event,
|
||||
GdkAtom *property,
|
||||
GdkAtom *target,
|
||||
GdkWindow **requestor);
|
||||
GDK_AVAILABLE_IN_3_92
|
||||
void gdk_event_set_selection (GdkEvent *event,
|
||||
GdkWindow *window,
|
||||
GdkAtom selection,
|
||||
guint32 time);
|
||||
GDK_AVAILABLE_IN_3_92
|
||||
gboolean gdk_event_get_axes (GdkEvent *event,
|
||||
gdouble **axes,
|
||||
guint *n_axes);
|
||||
|
@ -404,32 +404,6 @@ struct _GdkEventProperty
|
||||
guint state;
|
||||
};
|
||||
|
||||
/**
|
||||
* GdkEventSelection:
|
||||
* @type: the type of the event (%GDK_SELECTION_NOTIFY).
|
||||
* @window: the window which received the event.
|
||||
* @send_event: %TRUE if the event was sent explicitly.
|
||||
* @selection: the selection.
|
||||
* @target: the target to which the selection should be converted.
|
||||
* @property: the property in which to place the result of the conversion.
|
||||
* @time: the time of the event in milliseconds.
|
||||
* @requestor: the window on which to place @property or %NULL if none.
|
||||
*
|
||||
* Generated when a selection is requested or ownership of a selection
|
||||
* is taken over by another client application.
|
||||
*/
|
||||
struct _GdkEventSelection
|
||||
{
|
||||
GdkEventType type;
|
||||
GdkWindow *window;
|
||||
gint8 send_event;
|
||||
GdkAtom selection;
|
||||
GdkAtom target;
|
||||
GdkAtom property;
|
||||
guint32 time;
|
||||
GdkWindow *requestor;
|
||||
};
|
||||
|
||||
/**
|
||||
* GdkEventProximity:
|
||||
* @type: the type of the event (%GDK_PROXIMITY_IN or %GDK_PROXIMITY_OUT).
|
||||
@ -708,7 +682,6 @@ struct _GdkEventPadGroupMode {
|
||||
* @focus_change: a #GdkEventFocus
|
||||
* @configure: a #GdkEventConfigure
|
||||
* @property: a #GdkEventProperty
|
||||
* @selection: a #GdkEventSelection
|
||||
* @proximity: a #GdkEventProximity
|
||||
* @dnd: a #GdkEventDND
|
||||
* @window_state: a #GdkEventWindowState
|
||||
@ -764,7 +737,6 @@ union _GdkEvent
|
||||
GdkEventFocus focus_change;
|
||||
GdkEventConfigure configure;
|
||||
GdkEventProperty property;
|
||||
GdkEventSelection selection;
|
||||
GdkEventProximity proximity;
|
||||
GdkEventDND dnd;
|
||||
GdkEventWindowState window_state;
|
||||
|
@ -60,110 +60,6 @@
|
||||
* X Inter-client Communication Conventions Manual (ICCCM).
|
||||
*/
|
||||
|
||||
/**
|
||||
* gdk_selection_send_notify:
|
||||
* @requestor: window to which to deliver response.
|
||||
* @selection: selection that was requested.
|
||||
* @target: target that was selected.
|
||||
* @property: property in which the selection owner stored the
|
||||
* data, or %NULL to indicate that the request
|
||||
* was rejected.
|
||||
* @time_: timestamp.
|
||||
*
|
||||
* Sends a response to SelectionRequest event.
|
||||
*/
|
||||
void
|
||||
gdk_selection_send_notify (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
gdk_selection_send_notify_for_display (gdk_window_get_display (requestor),
|
||||
requestor, selection,
|
||||
target, property, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_selection_send_notify_for_display:
|
||||
* @display: the #GdkDisplay where @requestor is realized
|
||||
* @requestor: window to which to deliver response
|
||||
* @selection: selection that was requested
|
||||
* @target: target that was selected
|
||||
* @property: property in which the selection owner stored the data,
|
||||
* or %NULL to indicate that the request was rejected
|
||||
* @time_: timestamp
|
||||
*
|
||||
* Send a response to SelectionRequest event.
|
||||
*
|
||||
* Since: 2.2
|
||||
*/
|
||||
void
|
||||
gdk_selection_send_notify_for_display (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time_)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
GDK_DISPLAY_GET_CLASS (display)
|
||||
->send_selection_notify (display, requestor, selection,target, property, time_);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_selection_property_get: (skip)
|
||||
* @requestor: the window on which the data is stored
|
||||
* @data: location to store a pointer to the retrieved data.
|
||||
If the retrieval failed, %NULL we be stored here, otherwise, it
|
||||
will be non-%NULL and the returned data should be freed with g_free()
|
||||
when you are finished using it. The length of the
|
||||
allocated memory is one more than the length
|
||||
of the returned data, and the final byte will always
|
||||
be zero, to ensure nul-termination of strings
|
||||
* @prop_type: location to store the type of the property
|
||||
* @prop_format: location to store the format of the property
|
||||
*
|
||||
* Retrieves selection data that was stored by the selection
|
||||
* data in response to a call to gdk_selection_convert(). This function
|
||||
* will not be used by applications, who should use the #GtkClipboard
|
||||
* API instead.
|
||||
*
|
||||
* Returns: the length of the retrieved data.
|
||||
*/
|
||||
gint
|
||||
gdk_selection_property_get (GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
|
||||
|
||||
display = gdk_window_get_display (requestor);
|
||||
|
||||
return GDK_DISPLAY_GET_CLASS (display)
|
||||
->get_selection_property (display, requestor, data, ret_type, ret_format);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_selection_convert (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
|
||||
g_return_if_fail (selection != NULL);
|
||||
|
||||
display = gdk_window_get_display (requestor);
|
||||
|
||||
GDK_DISPLAY_GET_CLASS (display)
|
||||
->convert_selection (display, requestor, selection, target, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_text_property_to_utf8_list_for_display:
|
||||
* @display: a #GdkDisplay
|
||||
|
@ -152,46 +152,6 @@ G_BEGIN_DECLS
|
||||
/* Selections
|
||||
*/
|
||||
|
||||
/**
|
||||
* gdk_selection_convert:
|
||||
* @requestor: a #GdkWindow.
|
||||
* @selection: an atom identifying the selection to get the
|
||||
* contents of.
|
||||
* @target: the form in which to retrieve the selection.
|
||||
* @time_: the timestamp to use when retrieving the
|
||||
* selection. The selection owner may refuse the
|
||||
* request if it did not own the selection at
|
||||
* the time indicated by the timestamp.
|
||||
*
|
||||
* Retrieves the contents of a selection in a given
|
||||
* form.
|
||||
*/
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_selection_convert (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time_);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gint gdk_selection_property_get (GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *prop_type,
|
||||
gint *prop_format);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_selection_send_notify (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time_);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_selection_send_notify_for_display (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time_);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_SELECTION_H__ */
|
||||
|
@ -5468,10 +5468,6 @@ _gdk_make_event (GdkWindow *window,
|
||||
event->property.state = the_state;
|
||||
break;
|
||||
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
event->selection.time = the_time;
|
||||
break;
|
||||
|
||||
case GDK_PROXIMITY_IN:
|
||||
case GDK_PROXIMITY_OUT:
|
||||
event->proximity.time = the_time;
|
||||
|
@ -496,327 +496,6 @@ gdk_mir_display_pop_error_trap (GdkDisplay *display,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_display_send_selection_notify (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_mir_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
gint length;
|
||||
|
||||
gdk_property_get (requestor,
|
||||
gdk_atom_intern_static_string ("GDK_SELECTION"),
|
||||
NULL,
|
||||
0,
|
||||
G_MAXULONG,
|
||||
FALSE,
|
||||
ret_type,
|
||||
ret_format,
|
||||
&length,
|
||||
data);
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
static gint
|
||||
get_format_score (const gchar *format,
|
||||
GdkAtom target,
|
||||
GdkAtom *out_type,
|
||||
gint *out_size)
|
||||
{
|
||||
const gchar *target_string;
|
||||
GdkAtom dummy_type;
|
||||
gint dummy_size;
|
||||
|
||||
target_string = _gdk_atom_name_const (target);
|
||||
|
||||
if (!out_type)
|
||||
out_type = &dummy_type;
|
||||
|
||||
if (!out_size)
|
||||
out_size = &dummy_size;
|
||||
|
||||
if (!g_ascii_strcasecmp (format, target_string))
|
||||
{
|
||||
*out_type = GDK_SELECTION_TYPE_STRING;
|
||||
*out_size = sizeof (guchar);
|
||||
|
||||
return G_MAXINT;
|
||||
}
|
||||
|
||||
if (target == gdk_atom_intern_static_string ("UTF8_STRING"))
|
||||
return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size);
|
||||
|
||||
/* TODO: use best media type for COMPOUND_TEXT target */
|
||||
if (target == gdk_atom_intern_static_string ("COMPOUND_TEXT"))
|
||||
return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size);
|
||||
|
||||
if (target == GDK_TARGET_STRING)
|
||||
return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=iso-8859-1"), out_type, out_size);
|
||||
|
||||
if (target == gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"))
|
||||
return get_format_score (format, gdk_atom_intern_static_string ("text/plain;charset=utf-8"), out_type, out_size);
|
||||
|
||||
if (g_content_type_is_a (format, target_string))
|
||||
{
|
||||
*out_type = GDK_SELECTION_TYPE_STRING;
|
||||
*out_size = sizeof (guchar);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (g_content_type_is_a (target_string, format))
|
||||
{
|
||||
*out_type = GDK_SELECTION_TYPE_STRING;
|
||||
*out_size = sizeof (guchar);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gint
|
||||
get_best_format_index (const gchar * const *formats,
|
||||
guint n_formats,
|
||||
GdkAtom target,
|
||||
GdkAtom *out_type,
|
||||
gint *out_size)
|
||||
{
|
||||
gint best_i = -1;
|
||||
gint best_score = 0;
|
||||
GdkAtom best_type;
|
||||
gint best_size;
|
||||
gint score;
|
||||
GdkAtom type;
|
||||
gint size;
|
||||
gint i;
|
||||
|
||||
if (!out_type)
|
||||
out_type = &best_type;
|
||||
|
||||
if (!out_size)
|
||||
out_size = &best_size;
|
||||
|
||||
*out_type = NULL;
|
||||
*out_size = 0;
|
||||
|
||||
for (i = 0; i < n_formats; i++)
|
||||
{
|
||||
score = get_format_score (formats[i], target, &type, &size);
|
||||
|
||||
if (score > best_score)
|
||||
{
|
||||
best_i = i;
|
||||
best_score = score;
|
||||
*out_type = type;
|
||||
*out_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
return best_i;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_display_real_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
|
||||
const gchar *paste_data;
|
||||
gsize paste_size;
|
||||
const gint *paste_header;
|
||||
GPtrArray *paste_formats;
|
||||
GArray *paste_targets;
|
||||
GdkAtom paste_target;
|
||||
GdkEvent *event;
|
||||
gint best_i;
|
||||
GdkAtom best_type;
|
||||
gint best_size;
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (mir_display->paste_data);
|
||||
|
||||
paste_data = g_variant_get_fixed_array (mir_display->paste_data, &paste_size, sizeof (guchar));
|
||||
paste_header = (const gint *) paste_data;
|
||||
|
||||
if (paste_data)
|
||||
{
|
||||
paste_formats = g_ptr_array_new_full (paste_header[0], g_free);
|
||||
|
||||
for (i = 0; i < paste_header[0]; i++)
|
||||
g_ptr_array_add (paste_formats, g_strndup (paste_data + paste_header[1 + 4 * i], paste_header[2 + 4 * i]));
|
||||
}
|
||||
else
|
||||
paste_formats = g_ptr_array_new_with_free_func (g_free);
|
||||
|
||||
if (target == gdk_atom_intern_static_string ("TARGETS"))
|
||||
{
|
||||
paste_targets = g_array_sized_new (TRUE, FALSE, sizeof (GdkAtom), paste_formats->len);
|
||||
|
||||
for (i = 0; i < paste_formats->len; i++)
|
||||
{
|
||||
paste_target = gdk_atom_intern (g_ptr_array_index (paste_formats, i), FALSE);
|
||||
g_array_append_val (paste_targets, paste_target);
|
||||
}
|
||||
|
||||
gdk_property_change (requestor,
|
||||
gdk_atom_intern_static_string ("GDK_SELECTION"),
|
||||
GDK_SELECTION_TYPE_ATOM,
|
||||
8 * sizeof (GdkAtom),
|
||||
GDK_PROP_MODE_REPLACE,
|
||||
(const guchar *) paste_targets->data,
|
||||
paste_targets->len);
|
||||
|
||||
g_array_unref (paste_targets);
|
||||
|
||||
event = gdk_event_new (GDK_SELECTION_NOTIFY);
|
||||
event->selection.window = g_object_ref (requestor);
|
||||
event->selection.send_event = FALSE;
|
||||
event->selection.selection = selection;
|
||||
event->selection.target = target;
|
||||
event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION");
|
||||
event->selection.time = time;
|
||||
event->selection.requestor = g_object_ref (requestor);
|
||||
|
||||
gdk_event_put (event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
else
|
||||
{
|
||||
best_i = get_best_format_index ((const gchar * const *) paste_formats->pdata,
|
||||
paste_formats->len,
|
||||
target,
|
||||
&best_type,
|
||||
&best_size);
|
||||
|
||||
if (best_i >= 0)
|
||||
{
|
||||
gdk_property_change (requestor,
|
||||
gdk_atom_intern_static_string ("GDK_SELECTION"),
|
||||
best_type,
|
||||
8 * best_size,
|
||||
GDK_PROP_MODE_REPLACE,
|
||||
(const guchar *) paste_data + paste_header[3 + 4 * best_i],
|
||||
paste_header[4 + 4 * best_i] / best_size);
|
||||
|
||||
event = gdk_event_new (GDK_SELECTION_NOTIFY);
|
||||
event->selection.window = g_object_ref (requestor);
|
||||
event->selection.send_event = FALSE;
|
||||
event->selection.selection = selection;
|
||||
event->selection.target = target;
|
||||
event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION");
|
||||
event->selection.time = time;
|
||||
event->selection.requestor = g_object_ref (requestor);
|
||||
|
||||
gdk_event_put (event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
}
|
||||
|
||||
g_ptr_array_unref (paste_formats);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkWindow *requestor;
|
||||
GdkAtom selection;
|
||||
GdkAtom target;
|
||||
guint32 time;
|
||||
} ConvertInfo;
|
||||
|
||||
static void
|
||||
paste_data_ready_cb (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
ContentHubService *content_service = CONTENT_HUB_SERVICE (source_object);
|
||||
ConvertInfo *info = user_data;
|
||||
GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (info->display);
|
||||
gboolean result;
|
||||
|
||||
g_clear_pointer (&mir_display->paste_data, g_variant_unref);
|
||||
|
||||
result = content_hub_service_call_get_latest_paste_data_finish (content_service,
|
||||
&mir_display->paste_data,
|
||||
res,
|
||||
NULL);
|
||||
|
||||
if (result)
|
||||
gdk_mir_display_real_convert_selection (info->display,
|
||||
info->requestor,
|
||||
info->selection,
|
||||
info->target,
|
||||
info->time);
|
||||
|
||||
g_object_unref (info->requestor);
|
||||
g_object_unref (info->display);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_mir_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
GdkMirDisplay *mir_display = GDK_MIR_DISPLAY (display);
|
||||
MirWindow *mir_window;
|
||||
MirWindowId *mir_window_id;
|
||||
ConvertInfo *info;
|
||||
|
||||
if (selection != GDK_SELECTION_CLIPBOARD)
|
||||
return;
|
||||
else if (mir_display->paste_data)
|
||||
gdk_mir_display_real_convert_selection (display, requestor, selection, target, time);
|
||||
else if (mir_display->focused_window)
|
||||
{
|
||||
mir_window = _gdk_mir_window_get_mir_window (mir_display->focused_window);
|
||||
|
||||
if (!mir_window)
|
||||
return;
|
||||
|
||||
mir_window_id = mir_window_request_window_id_sync (mir_window);
|
||||
|
||||
if (!mir_window_id)
|
||||
return;
|
||||
|
||||
if (mir_window_id_is_valid (mir_window_id))
|
||||
{
|
||||
info = g_new (ConvertInfo, 1);
|
||||
info->display = g_object_ref (display);
|
||||
info->requestor = g_object_ref (requestor);
|
||||
info->selection = selection;
|
||||
info->target = target;
|
||||
info->time = time;
|
||||
|
||||
content_hub_service_call_get_latest_paste_data (
|
||||
mir_display->content_service,
|
||||
mir_window_id_as_string (mir_window_id),
|
||||
NULL,
|
||||
paste_data_ready_cb,
|
||||
info);
|
||||
}
|
||||
|
||||
mir_window_id_release (mir_window_id);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gdk_mir_display_text_property_to_utf8_list (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
@ -1176,9 +855,6 @@ gdk_mir_display_class_init (GdkMirDisplayClass *klass)
|
||||
display_class->get_keymap = gdk_mir_display_get_keymap;
|
||||
display_class->push_error_trap = gdk_mir_display_push_error_trap;
|
||||
display_class->pop_error_trap = gdk_mir_display_pop_error_trap;
|
||||
display_class->send_selection_notify = gdk_mir_display_send_selection_notify;
|
||||
display_class->get_selection_property = gdk_mir_display_get_selection_property;
|
||||
display_class->convert_selection = gdk_mir_display_convert_selection;
|
||||
display_class->text_property_to_utf8_list = gdk_mir_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = gdk_mir_display_utf8_to_string_target;
|
||||
display_class->make_gl_context_current = gdk_mir_display_make_gl_context_current;
|
||||
|
@ -276,8 +276,6 @@ gdk_quartz_display_class_init (GdkQuartzDisplayClass *class)
|
||||
display_class->event_data_free = _gdk_quartz_display_event_data_free;
|
||||
display_class->create_window_impl = _gdk_quartz_display_create_window_impl;
|
||||
display_class->get_keymap = _gdk_quartz_display_get_keymap;
|
||||
display_class->get_selection_property = _gdk_quartz_display_get_selection_property;
|
||||
display_class->convert_selection = _gdk_quartz_display_convert_selection;
|
||||
display_class->text_property_to_utf8_list = _gdk_quartz_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = _gdk_quartz_display_utf8_to_string_target;
|
||||
display_class->get_n_monitors = gdk_quartz_display_get_n_monitors;
|
||||
|
@ -71,17 +71,6 @@ void _gdk_quartz_display_create_window_impl (GdkDisplay *display,
|
||||
/* Display methods - keymap */
|
||||
GdkKeymap * _gdk_quartz_display_get_keymap (GdkDisplay *display);
|
||||
|
||||
/* Display methods - selection */
|
||||
gint _gdk_quartz_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format);
|
||||
void _gdk_quartz_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time);
|
||||
gint _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
gint format,
|
||||
|
@ -24,27 +24,6 @@
|
||||
#include "gdkproperty.h"
|
||||
#include "gdkquartz.h"
|
||||
|
||||
void
|
||||
_gdk_quartz_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_quartz_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
/* FIXME: Implement */
|
||||
return 0;
|
||||
}
|
||||
|
||||
gchar *
|
||||
_gdk_quartz_display_utf8_to_string_target (GdkDisplay *display,
|
||||
const gchar *str)
|
||||
|
@ -1019,9 +1019,6 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
|
||||
display_class->notify_startup_complete = gdk_wayland_display_notify_startup_complete;
|
||||
display_class->create_window_impl = _gdk_wayland_display_create_window_impl;
|
||||
display_class->get_keymap = _gdk_wayland_display_get_keymap;
|
||||
display_class->send_selection_notify = _gdk_wayland_display_send_selection_notify;
|
||||
display_class->get_selection_property = _gdk_wayland_display_get_selection_property;
|
||||
display_class->convert_selection = _gdk_wayland_display_convert_selection;
|
||||
display_class->text_property_to_utf8_list = _gdk_wayland_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = _gdk_wayland_display_utf8_to_string_target;
|
||||
|
||||
|
@ -78,7 +78,6 @@ struct _AsyncWriteData
|
||||
struct _SelectionData
|
||||
{
|
||||
DataOfferData *offer;
|
||||
GHashTable *buffers; /* Hashtable of target_atom->SelectionBuffer */
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -100,184 +99,14 @@ struct _GdkWaylandSelection
|
||||
struct wl_data_source *dnd_source; /* Owned by the GdkDragContext */
|
||||
};
|
||||
|
||||
static void selection_buffer_read (SelectionBuffer *buffer);
|
||||
static void async_write_data_write (AsyncWriteData *write_data);
|
||||
|
||||
static void
|
||||
_gdk_display_put_event (GdkDisplay *display,
|
||||
GdkEvent *event)
|
||||
{
|
||||
gdk_event_set_display (event, display);
|
||||
gdk_display_put_event (display, event);
|
||||
}
|
||||
|
||||
static void
|
||||
selection_buffer_notify (SelectionBuffer *buffer)
|
||||
{
|
||||
GdkEvent *event;
|
||||
GList *l;
|
||||
|
||||
for (l = buffer->requestors; l; l = l->next)
|
||||
{
|
||||
event = gdk_event_new (GDK_SELECTION_NOTIFY);
|
||||
event->selection.window = g_object_ref (l->data);
|
||||
event->selection.send_event = FALSE;
|
||||
event->selection.selection = buffer->selection;
|
||||
event->selection.target = buffer->target;
|
||||
event->selection.property = gdk_atom_intern_static_string ("GDK_SELECTION");
|
||||
event->selection.time = GDK_CURRENT_TIME;
|
||||
event->selection.requestor = g_object_ref (l->data);
|
||||
|
||||
_gdk_display_put_event (gdk_window_get_display (l->data), event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
}
|
||||
|
||||
static SelectionBuffer *
|
||||
selection_buffer_new (GInputStream *stream,
|
||||
GdkAtom selection,
|
||||
GdkAtom target)
|
||||
{
|
||||
SelectionBuffer *buffer;
|
||||
|
||||
buffer = g_new0 (SelectionBuffer, 1);
|
||||
buffer->stream = (stream) ? g_object_ref (stream) : NULL;
|
||||
buffer->cancellable = g_cancellable_new ();
|
||||
buffer->data = g_byte_array_new ();
|
||||
buffer->selection = selection;
|
||||
buffer->target = target;
|
||||
buffer->ref_count = 1;
|
||||
|
||||
if (stream)
|
||||
selection_buffer_read (buffer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static SelectionBuffer *
|
||||
selection_buffer_ref (SelectionBuffer *buffer)
|
||||
{
|
||||
buffer->ref_count++;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
selection_buffer_unref (SelectionBuffer *buffer_data)
|
||||
{
|
||||
buffer_data->ref_count--;
|
||||
|
||||
if (buffer_data->ref_count != 0)
|
||||
return;
|
||||
|
||||
if (buffer_data->cancellable)
|
||||
g_object_unref (buffer_data->cancellable);
|
||||
|
||||
if (buffer_data->stream)
|
||||
g_object_unref (buffer_data->stream);
|
||||
|
||||
if (buffer_data->data)
|
||||
g_byte_array_unref (buffer_data->data);
|
||||
|
||||
g_free (buffer_data);
|
||||
}
|
||||
|
||||
static void
|
||||
selection_buffer_append_data (SelectionBuffer *buffer,
|
||||
gconstpointer data,
|
||||
gsize len)
|
||||
{
|
||||
g_byte_array_append (buffer->data, data, len);
|
||||
}
|
||||
|
||||
static void
|
||||
selection_buffer_cancel_and_unref (SelectionBuffer *buffer_data)
|
||||
{
|
||||
if (buffer_data->cancellable)
|
||||
g_cancellable_cancel (buffer_data->cancellable);
|
||||
|
||||
selection_buffer_unref (buffer_data);
|
||||
}
|
||||
|
||||
static void
|
||||
selection_buffer_add_requestor (SelectionBuffer *buffer,
|
||||
GdkWindow *requestor)
|
||||
{
|
||||
if (!g_list_find (buffer->requestors, requestor))
|
||||
buffer->requestors = g_list_prepend (buffer->requestors,
|
||||
g_object_ref (requestor));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
selection_buffer_remove_requestor (SelectionBuffer *buffer,
|
||||
GdkWindow *requestor)
|
||||
{
|
||||
GList *link = g_list_find (buffer->requestors, requestor);
|
||||
|
||||
if (!link)
|
||||
return FALSE;
|
||||
|
||||
g_object_unref (link->data);
|
||||
buffer->requestors = g_list_delete_link (buffer->requestors, link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline glong
|
||||
get_buffer_size (void)
|
||||
{
|
||||
return sysconf (_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
static void
|
||||
selection_buffer_read_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
SelectionBuffer *buffer = user_data;
|
||||
gboolean finished = TRUE;
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
|
||||
bytes = g_input_stream_read_bytes_finish (buffer->stream, result, &error);
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
finished = g_bytes_get_size (bytes) < get_buffer_size ();
|
||||
selection_buffer_append_data (buffer,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes));
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
if (!finished)
|
||||
selection_buffer_read (buffer);
|
||||
else
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
g_warning (G_STRLOC ": error reading selection buffer: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
selection_buffer_notify (buffer);
|
||||
|
||||
g_input_stream_close (buffer->stream, NULL, NULL);
|
||||
g_clear_object (&buffer->stream);
|
||||
g_clear_object (&buffer->cancellable);
|
||||
}
|
||||
|
||||
selection_buffer_unref (buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
selection_buffer_read (SelectionBuffer *buffer)
|
||||
{
|
||||
selection_buffer_ref (buffer);
|
||||
g_input_stream_read_bytes_async (buffer->stream, get_buffer_size(),
|
||||
G_PRIORITY_DEFAULT,
|
||||
buffer->cancellable, selection_buffer_read_cb,
|
||||
buffer);
|
||||
}
|
||||
|
||||
static DataOfferData *
|
||||
data_offer_data_new (gpointer offer,
|
||||
GDestroyNotify destroy_notify)
|
||||
@ -304,18 +133,11 @@ GdkWaylandSelection *
|
||||
gdk_wayland_selection_new (void)
|
||||
{
|
||||
GdkWaylandSelection *selection;
|
||||
gint i;
|
||||
|
||||
/* init atoms */
|
||||
atoms[ATOM_DND] = gdk_atom_intern_static_string ("GdkWaylandSelection");
|
||||
|
||||
selection = g_new0 (GdkWaylandSelection, 1);
|
||||
for (i = 0; i < G_N_ELEMENTS (selection->selections); i++)
|
||||
{
|
||||
selection->selections[i].buffers =
|
||||
g_hash_table_new_full (NULL, NULL, NULL,
|
||||
(GDestroyNotify) selection_buffer_cancel_and_unref);
|
||||
}
|
||||
|
||||
selection->offers =
|
||||
g_hash_table_new_full (NULL, NULL, NULL,
|
||||
@ -327,11 +149,6 @@ gdk_wayland_selection_new (void)
|
||||
void
|
||||
gdk_wayland_selection_free (GdkWaylandSelection *selection)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (selection->selections); i++)
|
||||
g_hash_table_destroy (selection->selections[i].buffers);
|
||||
|
||||
g_hash_table_destroy (selection->offers);
|
||||
g_free (selection->stored_selection.data);
|
||||
|
||||
@ -513,8 +330,6 @@ gdk_wayland_selection_set_offer (GdkDisplay *display,
|
||||
if (selection_data)
|
||||
{
|
||||
selection_data->offer = info;
|
||||
/* Clear all buffers */
|
||||
g_hash_table_remove_all (selection_data->buffers);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,29 +518,6 @@ gdk_wayland_selection_store (GdkWindow *window,
|
||||
gdk_wayland_selection_check_write (selection);
|
||||
}
|
||||
|
||||
static SelectionBuffer *
|
||||
gdk_wayland_selection_lookup_requestor_buffer (GdkWindow *requestor)
|
||||
{
|
||||
GdkDisplay *display = gdk_window_get_display (requestor);
|
||||
GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
|
||||
SelectionBuffer *buffer_data;
|
||||
GHashTableIter iter;
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (selection->selections); i++)
|
||||
{
|
||||
g_hash_table_iter_init (&iter, selection->selections[i].buffers);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer*) &buffer_data))
|
||||
{
|
||||
if (g_list_find (buffer_data->requestors, requestor))
|
||||
return buffer_data;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
data_source_target (void *data,
|
||||
struct wl_data_source *source,
|
||||
@ -909,171 +701,6 @@ gdk_wayland_selection_unset_data_source (GdkDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_display_send_selection_notify (GdkDisplay *dispay,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_wayland_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
SelectionBuffer *buffer_data;
|
||||
gsize len;
|
||||
|
||||
buffer_data = gdk_wayland_selection_lookup_requestor_buffer (requestor);
|
||||
|
||||
if (!buffer_data)
|
||||
return 0;
|
||||
|
||||
selection_buffer_remove_requestor (buffer_data, requestor);
|
||||
len = buffer_data->data->len;
|
||||
|
||||
if (data)
|
||||
{
|
||||
guchar *buffer;
|
||||
|
||||
buffer = g_new0 (guchar, len + 1);
|
||||
memcpy (buffer, buffer_data->data->data, len);
|
||||
*data = buffer;
|
||||
}
|
||||
|
||||
if (buffer_data->target == gdk_atom_intern_static_string ("TARGETS"))
|
||||
{
|
||||
if (ret_type)
|
||||
*ret_type = GDK_SELECTION_TYPE_ATOM;
|
||||
if (ret_format)
|
||||
*ret_format = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ret_type)
|
||||
*ret_type = buffer_data->target;
|
||||
if (ret_format)
|
||||
*ret_format = 8;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static void
|
||||
emit_empty_selection_notify (GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target)
|
||||
{
|
||||
GdkEvent *event;
|
||||
|
||||
event = gdk_event_new (GDK_SELECTION_NOTIFY);
|
||||
event->selection.window = g_object_ref (requestor);
|
||||
event->selection.send_event = FALSE;
|
||||
event->selection.selection = selection;
|
||||
event->selection.target = target;
|
||||
event->selection.property = NULL;
|
||||
event->selection.time = GDK_CURRENT_TIME;
|
||||
event->selection.requestor = g_object_ref (requestor);
|
||||
|
||||
_gdk_display_put_event (gdk_window_get_display (requestor), event);
|
||||
gdk_event_free (event);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_wayland_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
GdkWaylandSelection *wayland_selection = gdk_wayland_display_get_selection (display);
|
||||
const SelectionData *selection_data;
|
||||
SelectionBuffer *buffer_data;
|
||||
gpointer offer;
|
||||
gchar *mimetype;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
selection_data = selection_lookup_offer_by_atom (wayland_selection, selection);
|
||||
if (!selection_data)
|
||||
return;
|
||||
|
||||
offer = gdk_wayland_selection_get_offer (display, selection);
|
||||
formats = gdk_wayland_selection_get_targets (display, selection);
|
||||
|
||||
if (!offer || target == gdk_atom_intern_static_string ("DELETE"))
|
||||
{
|
||||
emit_empty_selection_notify (requestor, selection, target);
|
||||
return;
|
||||
}
|
||||
|
||||
mimetype = gdk_atom_name (target);
|
||||
|
||||
if (target != gdk_atom_intern_static_string ("TARGETS"))
|
||||
{
|
||||
if (!gdk_content_formats_contain_mime_type (formats, GDK_ATOM_TO_POINTER (target)))
|
||||
{
|
||||
emit_empty_selection_notify (requestor, selection, target);
|
||||
return;
|
||||
}
|
||||
|
||||
wl_data_offer_accept (offer,
|
||||
_gdk_wayland_display_get_serial (GDK_WAYLAND_DISPLAY (display)),
|
||||
mimetype);
|
||||
}
|
||||
|
||||
buffer_data = g_hash_table_lookup (selection_data->buffers, target);
|
||||
|
||||
if (buffer_data)
|
||||
selection_buffer_add_requestor (buffer_data, requestor);
|
||||
else
|
||||
{
|
||||
GInputStream *stream = NULL;
|
||||
int pipe_fd[2];
|
||||
gsize n_targets = 0;
|
||||
const char * const *targets = NULL;
|
||||
|
||||
if (target == gdk_atom_intern_static_string ("TARGETS"))
|
||||
{
|
||||
targets = gdk_content_formats_get_mime_types (formats, &n_targets);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_unix_open_pipe (pipe_fd, FD_CLOEXEC, NULL);
|
||||
|
||||
wl_data_offer_receive (offer, mimetype, pipe_fd[1]);
|
||||
|
||||
stream = g_unix_input_stream_new (pipe_fd[0], TRUE);
|
||||
close (pipe_fd[1]);
|
||||
}
|
||||
|
||||
buffer_data = selection_buffer_new (stream, selection, target);
|
||||
selection_buffer_add_requestor (buffer_data, requestor);
|
||||
|
||||
if (stream)
|
||||
g_object_unref (stream);
|
||||
|
||||
if (targets)
|
||||
{
|
||||
/* Store directly the local atoms */
|
||||
selection_buffer_append_data (buffer_data, targets, n_targets * sizeof (const char * const *));
|
||||
}
|
||||
|
||||
g_hash_table_insert (selection_data->buffers,
|
||||
GDK_ATOM_TO_POINTER (target),
|
||||
buffer_data);
|
||||
}
|
||||
|
||||
if (!buffer_data->stream)
|
||||
selection_buffer_notify (buffer_data);
|
||||
|
||||
g_free (mimetype);
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_wayland_display_text_property_to_utf8_list (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
|
@ -1051,23 +1051,6 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
|
||||
|
||||
break;
|
||||
|
||||
case SelectionNotify:
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("selection notify:\twindow: %ld",
|
||||
xevent->xproperty.window));
|
||||
|
||||
event->selection.type = GDK_SELECTION_NOTIFY;
|
||||
event->selection.window = window;
|
||||
event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.selection);
|
||||
event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.target);
|
||||
if (xevent->xselection.property == None)
|
||||
event->selection.property = event->selection.target;
|
||||
else
|
||||
event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.property);
|
||||
event->selection.time = xevent->xselection.time;
|
||||
|
||||
break;
|
||||
|
||||
case ColormapNotify:
|
||||
GDK_NOTE (EVENTS,
|
||||
g_message ("colormap notify:\twindow: %ld",
|
||||
@ -3179,9 +3162,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
|
||||
display_class->notify_startup_complete = gdk_x11_display_notify_startup_complete;
|
||||
display_class->create_window_impl = _gdk_x11_display_create_window_impl;
|
||||
display_class->get_keymap = gdk_x11_display_get_keymap;
|
||||
display_class->send_selection_notify = _gdk_x11_display_send_selection_notify;
|
||||
display_class->get_selection_property = _gdk_x11_display_get_selection_property;
|
||||
display_class->convert_selection = _gdk_x11_display_convert_selection;
|
||||
display_class->text_property_to_utf8_list = _gdk_x11_display_text_property_to_utf8_list;
|
||||
display_class->utf8_to_string_target = _gdk_x11_display_utf8_to_string_target;
|
||||
|
||||
|
@ -145,23 +145,6 @@ void _gdk_x11_display_queue_events (GdkDisplay *display);
|
||||
|
||||
GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
|
||||
|
||||
void _gdk_x11_display_send_selection_notify (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time);
|
||||
gint _gdk_x11_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format);
|
||||
void _gdk_x11_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time);
|
||||
|
||||
gint _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display,
|
||||
GdkAtom encoding,
|
||||
gint format,
|
||||
|
@ -34,160 +34,6 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void
|
||||
_gdk_x11_display_convert_selection (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (selection != NULL);
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (requestor) || !GDK_WINDOW_IS_X11 (requestor))
|
||||
return;
|
||||
|
||||
if (!gdk_window_has_native (requestor))
|
||||
{
|
||||
g_warning ("Can't use selections on non-native window");
|
||||
return;
|
||||
}
|
||||
|
||||
XConvertSelection (GDK_WINDOW_XDISPLAY (requestor),
|
||||
gdk_x11_atom_to_xatom_for_display (display, selection),
|
||||
gdk_x11_atom_to_xatom_for_display (display, target),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "GDK_SELECTION"),
|
||||
GDK_WINDOW_XID (requestor), time);
|
||||
}
|
||||
|
||||
gint
|
||||
_gdk_x11_display_get_selection_property (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
guchar **data,
|
||||
GdkAtom *ret_type,
|
||||
gint *ret_format)
|
||||
{
|
||||
gulong nitems;
|
||||
gulong nbytes;
|
||||
gulong length = 0;
|
||||
Atom prop_type;
|
||||
gint prop_format;
|
||||
guchar *t = NULL;
|
||||
|
||||
if (GDK_WINDOW_DESTROYED (requestor) || !GDK_WINDOW_IS_X11 (requestor))
|
||||
goto err;
|
||||
|
||||
t = NULL;
|
||||
|
||||
/* We can't delete the selection here, because it might be the INCR
|
||||
protocol, in which case the client has to make sure they'll be
|
||||
notified of PropertyChange events _before_ the property is deleted.
|
||||
Otherwise there's no guarantee we'll win the race ... */
|
||||
if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (requestor),
|
||||
GDK_WINDOW_XID (requestor),
|
||||
gdk_x11_get_xatom_by_name_for_display (display, "GDK_SELECTION"),
|
||||
0, 0x1FFFFFFF /* MAXINT32 / 4 */, False,
|
||||
AnyPropertyType, &prop_type, &prop_format,
|
||||
&nitems, &nbytes, &t) != Success)
|
||||
goto err;
|
||||
|
||||
if (prop_type != None)
|
||||
{
|
||||
if (ret_type)
|
||||
*ret_type = gdk_x11_xatom_to_atom_for_display (display, prop_type);
|
||||
if (ret_format)
|
||||
*ret_format = prop_format;
|
||||
|
||||
if (prop_type == XA_ATOM ||
|
||||
prop_type == gdk_x11_get_xatom_by_name_for_display (display, "ATOM_PAIR"))
|
||||
{
|
||||
Atom* atoms = (Atom*) t;
|
||||
GdkAtom* atoms_dest;
|
||||
gint num_atom, i;
|
||||
|
||||
if (prop_format != 32)
|
||||
goto err;
|
||||
|
||||
num_atom = nitems;
|
||||
length = sizeof (GdkAtom) * num_atom + 1;
|
||||
|
||||
if (data)
|
||||
{
|
||||
*data = g_malloc (length);
|
||||
(*data)[length - 1] = '\0';
|
||||
atoms_dest = (GdkAtom *)(*data);
|
||||
|
||||
for (i=0; i < num_atom; i++)
|
||||
atoms_dest[i] = gdk_x11_xatom_to_atom_for_display (display, atoms[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (prop_format)
|
||||
{
|
||||
case 8:
|
||||
length = nitems;
|
||||
break;
|
||||
case 16:
|
||||
length = sizeof(short) * nitems;
|
||||
break;
|
||||
case 32:
|
||||
length = sizeof(long) * nitems;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Add on an extra byte to handle null termination. X guarantees
|
||||
that t will be 1 longer than nitems and null terminated */
|
||||
length += 1;
|
||||
|
||||
if (data)
|
||||
*data = g_memdup (t, length);
|
||||
}
|
||||
|
||||
if (t)
|
||||
XFree (t);
|
||||
|
||||
return length - 1;
|
||||
}
|
||||
|
||||
err:
|
||||
if (ret_type)
|
||||
*ret_type = NULL;
|
||||
if (ret_format)
|
||||
*ret_format = 0;
|
||||
if (data)
|
||||
*data = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_x11_display_send_selection_notify (GdkDisplay *display,
|
||||
GdkWindow *requestor,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
GdkAtom property,
|
||||
guint32 time)
|
||||
{
|
||||
XSelectionEvent xevent;
|
||||
|
||||
xevent.type = SelectionNotify;
|
||||
xevent.serial = 0;
|
||||
xevent.send_event = True;
|
||||
xevent.requestor = GDK_WINDOW_XID (requestor);
|
||||
xevent.selection = gdk_x11_atom_to_xatom_for_display (display, selection);
|
||||
xevent.target = gdk_x11_atom_to_xatom_for_display (display, target);
|
||||
if (property == NULL)
|
||||
xevent.property = None;
|
||||
else
|
||||
xevent.property = gdk_x11_atom_to_xatom_for_display (display, property);
|
||||
xevent.time = time;
|
||||
|
||||
_gdk_x11_display_send_xevent (display, xevent.requestor, False, NoEventMask, (XEvent*) & xevent);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_x11_display_text_property_to_text_list:
|
||||
* @display: (type GdkX11Display): The #GdkDisplay where the encoding is defined
|
||||
|
@ -1636,7 +1636,6 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
|
||||
|
||||
g_clear_object (&info->widget);
|
||||
|
||||
gtk_selection_remove_all (info->ipc_widget);
|
||||
g_object_set_data (G_OBJECT (info->ipc_widget), I_("gtk-info"), NULL);
|
||||
source_widgets = g_slist_remove (source_widgets, info->ipc_widget);
|
||||
gtk_drag_release_ipc_widget (info->ipc_widget);
|
||||
|
@ -1692,19 +1692,7 @@ gtk_main_do_event (GdkEvent *event)
|
||||
*/
|
||||
event_widget = gtk_get_event_widget (event);
|
||||
if (!event_widget)
|
||||
{
|
||||
/* To handle selection INCR transactions, we select
|
||||
* PropertyNotify events on the requestor window and create
|
||||
* a corresponding (fake) GdkWindow so that events get here.
|
||||
* There won't be a widget though, so we have to handle
|
||||
* them specially
|
||||
*/
|
||||
if (event->type == GDK_PROPERTY_NOTIFY)
|
||||
_gtk_selection_incr_event (event->any.window,
|
||||
&event->property);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
/* If pointer or keyboard grabs are in effect, munge the events
|
||||
* so that each window group looks like a separate app.
|
||||
@ -1823,7 +1811,6 @@ gtk_main_do_event (GdkEvent *event)
|
||||
case GDK_CONFIGURE:
|
||||
case GDK_MAP:
|
||||
case GDK_UNMAP:
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
case GDK_CLIENT_EVENT:
|
||||
case GDK_WINDOW_STATE:
|
||||
case GDK_GRAB_BROKEN:
|
||||
|
@ -104,96 +104,6 @@
|
||||
#include <gdk/wayland/gdkwayland.h>
|
||||
#endif
|
||||
|
||||
#undef DEBUG_SELECTION
|
||||
|
||||
/* Maximum size of a sent chunk, in bytes. Also the default size of
|
||||
our buffers */
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#define GTK_SELECTION_MAX_SIZE(display) \
|
||||
GDK_IS_X11_DISPLAY (display) ? \
|
||||
MIN(262144, \
|
||||
XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0 \
|
||||
? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100 \
|
||||
: XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100)\
|
||||
: G_MAXINT
|
||||
#else
|
||||
/* No chunks on Win32 */
|
||||
#define GTK_SELECTION_MAX_SIZE(display) G_MAXINT
|
||||
#endif
|
||||
|
||||
#define IDLE_ABORT_TIME 30
|
||||
|
||||
enum {
|
||||
INCR,
|
||||
MULTIPLE,
|
||||
TARGETS,
|
||||
TIMESTAMP,
|
||||
SAVE_TARGETS,
|
||||
LAST_ATOM
|
||||
};
|
||||
|
||||
typedef struct _GtkIncrConversion GtkIncrConversion;
|
||||
typedef struct _GtkIncrInfo GtkIncrInfo;
|
||||
typedef struct _GtkRetrievalInfo GtkRetrievalInfo;
|
||||
|
||||
struct _GtkIncrConversion
|
||||
{
|
||||
GdkAtom target; /* Requested target */
|
||||
GdkAtom property; /* Property to store in */
|
||||
GtkSelectionData data; /* The data being supplied */
|
||||
gint offset; /* Current offset in sent selection.
|
||||
* -1 => All done
|
||||
* -2 => Only the final (empty) portion
|
||||
* left to send */
|
||||
};
|
||||
|
||||
struct _GtkIncrInfo
|
||||
{
|
||||
GdkWindow *requestor; /* Requestor window - we create a GdkWindow
|
||||
so we can receive events */
|
||||
GdkAtom selection; /* Selection we're sending */
|
||||
|
||||
GtkIncrConversion *conversions; /* Information about requested conversions -
|
||||
* With MULTIPLE requests (benighted 1980's
|
||||
* hardware idea), there can be more than
|
||||
* one */
|
||||
gint num_conversions;
|
||||
gint num_incrs; /* number of remaining INCR style transactions */
|
||||
guint32 idle_time;
|
||||
};
|
||||
|
||||
|
||||
struct _GtkRetrievalInfo
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GdkAtom selection; /* Selection being retrieved. */
|
||||
GdkAtom target; /* Form of selection that we requested */
|
||||
guint32 idle_time; /* Number of seconds since we last heard
|
||||
from selection owner */
|
||||
guchar *buffer; /* Buffer in which to accumulate results */
|
||||
gint offset; /* Current offset in buffer, -1 indicates
|
||||
not yet started */
|
||||
guint32 notify_time; /* Timestamp from SelectionNotify */
|
||||
};
|
||||
|
||||
/* Local Functions */
|
||||
static void gtk_selection_init (void);
|
||||
static gboolean gtk_selection_retrieval_timeout (GtkRetrievalInfo *info);
|
||||
static void gtk_selection_retrieval_report (GtkRetrievalInfo *info,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
guchar *buffer,
|
||||
gint length,
|
||||
guint32 time);
|
||||
static int gtk_selection_bytes_per_item (gint format);
|
||||
|
||||
/* Local Data */
|
||||
static gint initialize = TRUE;
|
||||
static GList *current_retrievals = NULL;
|
||||
static GList *current_incrs = NULL;
|
||||
|
||||
static GdkAtom gtk_selection_atoms[LAST_ATOM];
|
||||
|
||||
/****************
|
||||
* Target Lists *
|
||||
****************/
|
||||
@ -363,110 +273,6 @@ gtk_content_formats_add_uri_targets (GdkContentFormats *list)
|
||||
return gdk_content_formats_builder_free (builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_remove_all:
|
||||
* @widget: a #GtkWidget
|
||||
*
|
||||
* Removes all handlers and unsets ownership of all
|
||||
* selections for a widget. Called when widget is being
|
||||
* destroyed. This function will not generally be
|
||||
* called by applications.
|
||||
**/
|
||||
void
|
||||
gtk_selection_remove_all (GtkWidget *widget)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GList *next;
|
||||
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
/* Remove pending requests/incrs for this widget */
|
||||
|
||||
tmp_list = current_retrievals;
|
||||
while (tmp_list)
|
||||
{
|
||||
next = tmp_list->next;
|
||||
if (((GtkRetrievalInfo *)tmp_list->data)->widget == widget)
|
||||
{
|
||||
current_retrievals = g_list_remove_link (current_retrievals,
|
||||
tmp_list);
|
||||
/* structure will be freed in timeout */
|
||||
g_list_free (tmp_list);
|
||||
}
|
||||
tmp_list = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_selection_convert:
|
||||
* @widget: The widget which acts as requestor
|
||||
* @selection: Which selection to get
|
||||
* @target: Form of information desired (e.g., STRING)
|
||||
* @time_: Time of request (usually of triggering event)
|
||||
In emergency, you could use #GDK_CURRENT_TIME
|
||||
*
|
||||
* Requests the contents of a selection. When received,
|
||||
* a “selection-received” signal will be generated.
|
||||
*
|
||||
* Returns: %TRUE if requested succeeded. %FALSE if we could not process
|
||||
* request. (e.g., there was already a request in process for
|
||||
* this widget).
|
||||
**/
|
||||
gboolean
|
||||
gtk_selection_convert (GtkWidget *widget,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time_)
|
||||
{
|
||||
GtkRetrievalInfo *info;
|
||||
GList *tmp_list;
|
||||
guint id;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
|
||||
g_return_val_if_fail (selection != NULL, FALSE);
|
||||
|
||||
if (initialize)
|
||||
gtk_selection_init ();
|
||||
|
||||
if (!gtk_widget_get_realized (widget))
|
||||
gtk_widget_realize (widget);
|
||||
|
||||
/* Check to see if there are already any retrievals in progress for
|
||||
this widget. If we changed GDK to use the selection for the
|
||||
window property in which to store the retrieved information, then
|
||||
we could support multiple retrievals for different selections.
|
||||
This might be useful for DND. */
|
||||
|
||||
tmp_list = current_retrievals;
|
||||
while (tmp_list)
|
||||
{
|
||||
info = (GtkRetrievalInfo *)tmp_list->data;
|
||||
if (info->widget == widget)
|
||||
return FALSE;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
info = g_slice_new (GtkRetrievalInfo);
|
||||
|
||||
info->widget = widget;
|
||||
info->selection = selection;
|
||||
info->target = target;
|
||||
info->idle_time = 0;
|
||||
info->buffer = NULL;
|
||||
info->offset = -1;
|
||||
|
||||
/* Otherwise, we need to go through X */
|
||||
|
||||
current_retrievals = g_list_append (current_retrievals, info);
|
||||
gdk_selection_convert (gtk_widget_get_window (widget), selection, target, time_);
|
||||
id = gdk_threads_add_timeout (1000,
|
||||
(GSourceFunc) gtk_selection_retrieval_timeout, info);
|
||||
g_source_set_name_by_id (id, "[gtk+] gtk_selection_retrieval_timeout");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_data_get_selection:
|
||||
* @selection_data: a pointer to a #GtkSelectionData-struct.
|
||||
@ -1570,453 +1376,6 @@ gtk_selection_data_targets_include_uri (const GtkSelectionData *selection_data)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
* gtk_selection_init:
|
||||
* Initialize local variables
|
||||
* arguments:
|
||||
*
|
||||
* results:
|
||||
*************************************************************/
|
||||
|
||||
static void
|
||||
gtk_selection_init (void)
|
||||
{
|
||||
gtk_selection_atoms[INCR] = gdk_atom_intern_static_string ("INCR");
|
||||
gtk_selection_atoms[MULTIPLE] = gdk_atom_intern_static_string ("MULTIPLE");
|
||||
gtk_selection_atoms[TIMESTAMP] = gdk_atom_intern_static_string ("TIMESTAMP");
|
||||
gtk_selection_atoms[TARGETS] = gdk_atom_intern_static_string ("TARGETS");
|
||||
gtk_selection_atoms[SAVE_TARGETS] = gdk_atom_intern_static_string ("SAVE_TARGETS");
|
||||
|
||||
initialize = FALSE;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* _gtk_selection_incr_event:
|
||||
* Called whenever an PropertyNotify event occurs for an
|
||||
* GdkWindow with user_data == NULL. These will be notifications
|
||||
* that a window we are sending the selection to via the
|
||||
* INCR protocol has deleted a property and is ready for
|
||||
* more data.
|
||||
*
|
||||
* arguments:
|
||||
* window: the requestor window
|
||||
* event: the property event structure
|
||||
*
|
||||
* results:
|
||||
*************************************************************/
|
||||
|
||||
gboolean
|
||||
_gtk_selection_incr_event (GdkWindow *window,
|
||||
GdkEventProperty *event)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GtkIncrInfo *info = NULL;
|
||||
gint num_bytes;
|
||||
guchar *buffer;
|
||||
gulong selection_max_size;
|
||||
GdkPropertyState state;
|
||||
GdkAtom atom;
|
||||
int i;
|
||||
GdkDisplay *display;
|
||||
|
||||
gdk_event_get_property ((GdkEvent *)event, &atom, &state);
|
||||
if (state != GDK_PROPERTY_DELETE)
|
||||
return FALSE;
|
||||
|
||||
#ifdef DEBUG_SELECTION
|
||||
g_message ("PropertyDelete, property %ld", atom);
|
||||
#endif
|
||||
|
||||
display = gdk_window_get_display (window);
|
||||
selection_max_size = GTK_SELECTION_MAX_SIZE (display);
|
||||
|
||||
/* Now find the appropriate ongoing INCR */
|
||||
tmp_list = current_incrs;
|
||||
while (tmp_list)
|
||||
{
|
||||
info = (GtkIncrInfo *)tmp_list->data;
|
||||
if (info->requestor == gdk_event_get_window ((GdkEvent *)event))
|
||||
break;
|
||||
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if (tmp_list == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Find out which target this is for */
|
||||
for (i=0; i<info->num_conversions; i++)
|
||||
{
|
||||
if (info->conversions[i].property == atom &&
|
||||
info->conversions[i].offset != -1)
|
||||
{
|
||||
int bytes_per_item;
|
||||
|
||||
info->idle_time = 0;
|
||||
|
||||
if (info->conversions[i].offset == -2) /* only the last 0-length
|
||||
piece*/
|
||||
{
|
||||
num_bytes = 0;
|
||||
buffer = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
num_bytes = info->conversions[i].data.length -
|
||||
info->conversions[i].offset;
|
||||
buffer = info->conversions[i].data.data +
|
||||
info->conversions[i].offset;
|
||||
|
||||
if (num_bytes > selection_max_size)
|
||||
{
|
||||
num_bytes = selection_max_size;
|
||||
info->conversions[i].offset += selection_max_size;
|
||||
}
|
||||
else
|
||||
info->conversions[i].offset = -2;
|
||||
}
|
||||
#ifdef DEBUG_SELECTION
|
||||
g_message ("INCR: put %d bytes (offset = %d) into window 0x%lx , property %ld",
|
||||
num_bytes, info->conversions[i].offset,
|
||||
GDK_WINDOW_XID(info->requestor), atom);
|
||||
#endif
|
||||
|
||||
bytes_per_item = gtk_selection_bytes_per_item (info->conversions[i].data.format);
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (GDK_IS_X11_DISPLAY (display))
|
||||
gdk_x11_display_error_trap_push (display);
|
||||
#endif
|
||||
|
||||
gdk_property_change (info->requestor, atom,
|
||||
info->conversions[i].data.type,
|
||||
info->conversions[i].data.format,
|
||||
GDK_PROP_MODE_REPLACE,
|
||||
buffer,
|
||||
num_bytes / bytes_per_item);
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (GDK_IS_X11_DISPLAY (display))
|
||||
gdk_x11_display_error_trap_pop_ignored (display);
|
||||
#endif
|
||||
|
||||
if (info->conversions[i].offset == -2)
|
||||
{
|
||||
g_free (info->conversions[i].data.data);
|
||||
info->conversions[i].data.data = NULL;
|
||||
}
|
||||
|
||||
if (num_bytes == 0)
|
||||
{
|
||||
info->num_incrs--;
|
||||
info->conversions[i].offset = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we're finished with all the targets */
|
||||
|
||||
if (info->num_incrs == 0)
|
||||
{
|
||||
current_incrs = g_list_remove_link (current_incrs, tmp_list);
|
||||
g_list_free (tmp_list);
|
||||
/* Let the timeout free it */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* _gtk_selection_notify:
|
||||
* Handler for “selection-notify-event” signals on windows
|
||||
* where a retrieval is currently in process. The selection
|
||||
* owner has responded to our conversion request.
|
||||
* arguments:
|
||||
* widget: Widget getting signal
|
||||
* event: Selection event structure
|
||||
* info: Information about this retrieval
|
||||
* results:
|
||||
* was event handled?
|
||||
*************************************************************/
|
||||
|
||||
gboolean
|
||||
_gtk_selection_notify (GtkWidget *widget,
|
||||
GdkEventSelection *event)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GtkRetrievalInfo *info = NULL;
|
||||
GdkWindow *window;
|
||||
guchar *buffer = NULL;
|
||||
gint length;
|
||||
GdkAtom type;
|
||||
GdkAtom selection;
|
||||
GdkAtom property;
|
||||
gint format;
|
||||
guint32 time;
|
||||
|
||||
gdk_event_get_selection ((GdkEvent *)event, &selection);
|
||||
gdk_event_get_selection_property ((GdkEvent *)event, &property, NULL, NULL);
|
||||
time = gdk_event_get_time ((GdkEvent *)event);
|
||||
|
||||
#ifdef DEBUG_SELECTION
|
||||
g_message ("Initial receipt of selection %ld, target %ld (property = %ld)",
|
||||
selection, target, property);
|
||||
#endif
|
||||
|
||||
window = gtk_widget_get_window (widget);
|
||||
|
||||
tmp_list = current_retrievals;
|
||||
while (tmp_list)
|
||||
{
|
||||
info = (GtkRetrievalInfo *)tmp_list->data;
|
||||
if (info->widget == widget && info->selection == selection)
|
||||
break;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if (!tmp_list) /* no retrieval in progress */
|
||||
return FALSE;
|
||||
|
||||
if (property != NULL)
|
||||
length = gdk_selection_property_get (window, &buffer,
|
||||
&type, &format);
|
||||
else
|
||||
length = 0; /* silence gcc */
|
||||
|
||||
if (property == NULL || buffer == NULL)
|
||||
{
|
||||
current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
|
||||
g_list_free (tmp_list);
|
||||
/* structure will be freed in timeout */
|
||||
gtk_selection_retrieval_report (info, NULL, 0, NULL, -1, time);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (type == gtk_selection_atoms[INCR])
|
||||
{
|
||||
/* The remainder of the selection will come through PropertyNotify
|
||||
events */
|
||||
|
||||
info->notify_time = time;
|
||||
info->idle_time = 0;
|
||||
info->offset = 0; /* Mark as OK to proceed */
|
||||
gdk_window_set_events (window,
|
||||
gdk_window_get_events (window)
|
||||
| GDK_PROPERTY_CHANGE_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We don't delete the info structure - that will happen in timeout */
|
||||
current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
|
||||
g_list_free (tmp_list);
|
||||
|
||||
info->offset = length;
|
||||
gtk_selection_retrieval_report (info,
|
||||
type, format,
|
||||
buffer, length, time);
|
||||
}
|
||||
|
||||
gdk_property_delete (window, property);
|
||||
|
||||
g_free (buffer);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* _gtk_selection_property_notify:
|
||||
* Handler for “property-notify-event” signals on windows
|
||||
* where a retrieval is currently in process. The selection
|
||||
* owner has added more data.
|
||||
* arguments:
|
||||
* widget: Widget getting signal
|
||||
* event: Property event structure
|
||||
* info: Information about this retrieval
|
||||
* results:
|
||||
* was event handled?
|
||||
*************************************************************/
|
||||
|
||||
gboolean
|
||||
_gtk_selection_property_notify (GtkWidget *widget,
|
||||
GdkEventProperty *event)
|
||||
{
|
||||
GList *tmp_list;
|
||||
GtkRetrievalInfo *info = NULL;
|
||||
GdkWindow *window;
|
||||
guchar *new_buffer;
|
||||
int length;
|
||||
GdkAtom type;
|
||||
gint format;
|
||||
GdkAtom property;
|
||||
GdkPropertyState state;
|
||||
|
||||
g_return_val_if_fail (widget != NULL, FALSE);
|
||||
g_return_val_if_fail (event != NULL, FALSE);
|
||||
|
||||
gdk_event_get_property ((GdkEvent *)event, &property, &state);
|
||||
|
||||
#if defined(GDK_WINDOWING_WIN32) || defined(GDK_WINDOWING_X11)
|
||||
if ((state != GDK_PROPERTY_NEW_VALUE) || /* property was deleted */
|
||||
(property != gdk_atom_intern_static_string ("GDK_SELECTION"))) /* not the right property */
|
||||
#endif
|
||||
return FALSE;
|
||||
|
||||
#ifdef DEBUG_SELECTION
|
||||
g_message ("PropertyNewValue, property %ld", property);
|
||||
#endif
|
||||
|
||||
tmp_list = current_retrievals;
|
||||
while (tmp_list)
|
||||
{
|
||||
info = (GtkRetrievalInfo *)tmp_list->data;
|
||||
if (info->widget == widget)
|
||||
break;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
if (!tmp_list) /* No retrieval in progress */
|
||||
return FALSE;
|
||||
|
||||
if (info->offset < 0) /* We haven't got the SelectionNotify
|
||||
for this retrieval yet */
|
||||
return FALSE;
|
||||
|
||||
info->idle_time = 0;
|
||||
|
||||
window = gtk_widget_get_window (widget);
|
||||
length = gdk_selection_property_get (window, &new_buffer,
|
||||
&type, &format);
|
||||
gdk_property_delete (window, property);
|
||||
|
||||
/* We could do a lot better efficiency-wise by paying attention to
|
||||
what length was sent in the initial INCR transaction, instead of
|
||||
doing memory allocation at every step. But its only guaranteed to
|
||||
be a _lower bound_ (pretty useless!) */
|
||||
|
||||
if (length == 0 || type == NULL) /* final zero length portion */
|
||||
{
|
||||
/* Info structure will be freed in timeout */
|
||||
current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
|
||||
g_list_free (tmp_list);
|
||||
gtk_selection_retrieval_report (info,
|
||||
type, format,
|
||||
(type == NULL) ? NULL : info->buffer,
|
||||
(type == NULL) ? -1 : info->offset,
|
||||
info->notify_time);
|
||||
}
|
||||
else /* append on newly arrived data */
|
||||
{
|
||||
if (!info->buffer)
|
||||
{
|
||||
#ifdef DEBUG_SELECTION
|
||||
g_message ("Start - Adding %d bytes at offset 0",
|
||||
length);
|
||||
#endif
|
||||
info->buffer = new_buffer;
|
||||
info->offset = length;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#ifdef DEBUG_SELECTION
|
||||
g_message ("Appending %d bytes at offset %d",
|
||||
length,info->offset);
|
||||
#endif
|
||||
/* We copy length+1 bytes to preserve guaranteed null termination */
|
||||
info->buffer = g_realloc (info->buffer, info->offset+length+1);
|
||||
memcpy (info->buffer + info->offset, new_buffer, length+1);
|
||||
info->offset += length;
|
||||
g_free (new_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* gtk_selection_retrieval_timeout:
|
||||
* Timeout callback while receiving a selection.
|
||||
* arguments:
|
||||
* info: Information about this retrieval
|
||||
* results:
|
||||
*************************************************************/
|
||||
|
||||
static gboolean
|
||||
gtk_selection_retrieval_timeout (GtkRetrievalInfo *info)
|
||||
{
|
||||
GList *tmp_list;
|
||||
gboolean retval;
|
||||
|
||||
/* Determine if retrieval has finished by checking if it still in
|
||||
list of pending retrievals */
|
||||
|
||||
tmp_list = current_retrievals;
|
||||
while (tmp_list)
|
||||
{
|
||||
if (info == (GtkRetrievalInfo *)tmp_list->data)
|
||||
break;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
/* If retrieval is finished */
|
||||
if (!tmp_list || info->idle_time >= IDLE_ABORT_TIME)
|
||||
{
|
||||
if (tmp_list && info->idle_time >= IDLE_ABORT_TIME)
|
||||
{
|
||||
current_retrievals = g_list_remove_link (current_retrievals, tmp_list);
|
||||
g_list_free (tmp_list);
|
||||
gtk_selection_retrieval_report (info, NULL, 0, NULL, -1, GDK_CURRENT_TIME);
|
||||
}
|
||||
|
||||
g_free (info->buffer);
|
||||
g_slice_free (GtkRetrievalInfo, info);
|
||||
|
||||
retval = FALSE; /* remove timeout */
|
||||
}
|
||||
else
|
||||
{
|
||||
info->idle_time++;
|
||||
|
||||
retval = TRUE; /* timeout will happen again */
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*************************************************************
|
||||
* gtk_selection_retrieval_report:
|
||||
* Emits a “selection-received” signal.
|
||||
* arguments:
|
||||
* info: information about the retrieval that completed
|
||||
* buffer: buffer containing data (NULL => errror)
|
||||
* time: timestamp for data in buffer
|
||||
* results:
|
||||
*************************************************************/
|
||||
|
||||
static void
|
||||
gtk_selection_retrieval_report (GtkRetrievalInfo *info,
|
||||
GdkAtom type, gint format,
|
||||
guchar *buffer, gint length,
|
||||
guint32 time)
|
||||
{
|
||||
GtkSelectionData data;
|
||||
|
||||
data.selection = info->selection;
|
||||
data.target = info->target;
|
||||
data.type = type;
|
||||
data.format = format;
|
||||
|
||||
data.length = length;
|
||||
data.data = buffer;
|
||||
data.display = gtk_widget_get_display (info->widget);
|
||||
|
||||
g_signal_emit_by_name (info->widget,
|
||||
"selection-received",
|
||||
&data, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_data_copy:
|
||||
* @data: a pointer to a #GtkSelectionData-struct.
|
||||
@ -2065,22 +1424,3 @@ G_DEFINE_BOXED_TYPE (GtkSelectionData, gtk_selection_data,
|
||||
gtk_selection_data_copy,
|
||||
gtk_selection_data_free)
|
||||
|
||||
static int
|
||||
gtk_selection_bytes_per_item (gint format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case 8:
|
||||
return sizeof (char);
|
||||
break;
|
||||
case 16:
|
||||
return sizeof (short);
|
||||
break;
|
||||
case 32:
|
||||
return sizeof (long);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -44,14 +44,6 @@ GdkContentFormats * gtk_content_formats_add_image_targets (GdkContentFor
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkContentFormats * gtk_content_formats_add_uri_targets (GdkContentFormats *list) G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_selection_convert (GtkWidget *widget,
|
||||
GdkAtom selection,
|
||||
GdkAtom target,
|
||||
guint32 time_);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_selection_remove_all (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkAtom gtk_selection_data_get_selection (const GtkSelectionData *selection_data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -47,13 +47,6 @@ struct _GtkSelectionData
|
||||
GdkDisplay *display;
|
||||
};
|
||||
|
||||
gboolean _gtk_selection_incr_event (GdkWindow *window,
|
||||
GdkEventProperty *event);
|
||||
gboolean _gtk_selection_notify (GtkWidget *widget,
|
||||
GdkEventSelection *event);
|
||||
gboolean _gtk_selection_property_notify (GtkWidget *widget,
|
||||
GdkEventProperty *event);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_SELECTION_PRIVATE_H__ */
|
||||
|
@ -521,7 +521,6 @@ enum {
|
||||
MAP_EVENT,
|
||||
UNMAP_EVENT,
|
||||
PROPERTY_NOTIFY_EVENT,
|
||||
SELECTION_NOTIFY_EVENT,
|
||||
SELECTION_GET,
|
||||
SELECTION_RECEIVED,
|
||||
PROXIMITY_IN_EVENT,
|
||||
@ -1045,8 +1044,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
klass->map_event = NULL;
|
||||
klass->unmap_event = NULL;
|
||||
klass->window_state_event = NULL;
|
||||
klass->property_notify_event = _gtk_selection_property_notify;
|
||||
klass->selection_notify_event = _gtk_selection_notify;
|
||||
klass->property_notify_event = NULL;
|
||||
klass->selection_received = NULL;
|
||||
klass->proximity_in_event = NULL;
|
||||
klass->proximity_out_event = NULL;
|
||||
@ -2429,25 +2427,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
g_signal_set_va_marshaller (widget_signals[PROPERTY_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_BOOLEAN__BOXEDv);
|
||||
|
||||
/**
|
||||
* GtkWidget::selection-notify-event:
|
||||
* @widget: the object which received the signal.
|
||||
* @event: (type Gdk.EventSelection):
|
||||
*
|
||||
* Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further.
|
||||
*/
|
||||
widget_signals[SELECTION_NOTIFY_EVENT] =
|
||||
g_signal_new (I_("selection-notify-event"),
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_DEPRECATED,
|
||||
G_STRUCT_OFFSET (GtkWidgetClass, selection_notify_event),
|
||||
_gtk_boolean_handled_accumulator, NULL,
|
||||
_gtk_marshal_BOOLEAN__BOXED,
|
||||
G_TYPE_BOOLEAN, 1,
|
||||
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
|
||||
g_signal_set_va_marshaller (widget_signals[SELECTION_NOTIFY_EVENT], G_TYPE_FROM_CLASS (klass),
|
||||
_gtk_marshal_BOOLEAN__BOXEDv);
|
||||
|
||||
/**
|
||||
* GtkWidget::selection-received:
|
||||
* @widget: the object which received the signal.
|
||||
@ -6623,7 +6602,6 @@ gtk_widget_event_internal (GtkWidget *widget,
|
||||
case GDK_UNMAP:
|
||||
case GDK_WINDOW_STATE:
|
||||
case GDK_PROPERTY_NOTIFY:
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
return gtk_widget_emit_event_signals (widget, event);
|
||||
default:
|
||||
break;
|
||||
@ -6743,9 +6721,6 @@ gtk_widget_emit_event_signals (GtkWidget *widget,
|
||||
case GDK_PROPERTY_NOTIFY:
|
||||
signal_num = PROPERTY_NOTIFY_EVENT;
|
||||
break;
|
||||
case GDK_SELECTION_NOTIFY:
|
||||
signal_num = SELECTION_NOTIFY_EVENT;
|
||||
break;
|
||||
case GDK_PROXIMITY_IN:
|
||||
signal_num = PROXIMITY_IN_EVENT;
|
||||
break;
|
||||
@ -10147,8 +10122,6 @@ gtk_widget_real_unrealize (GtkWidget *widget)
|
||||
priv->window = NULL;
|
||||
}
|
||||
|
||||
gtk_selection_remove_all (widget);
|
||||
|
||||
gtk_widget_set_realized (widget, FALSE);
|
||||
}
|
||||
|
||||
|
@ -369,12 +369,6 @@ struct _GtkWidgetClass
|
||||
GdkEventAny *event);
|
||||
gboolean (* property_notify_event) (GtkWidget *widget,
|
||||
GdkEventProperty *event);
|
||||
gboolean (* selection_clear_event) (GtkWidget *widget,
|
||||
GdkEventSelection *event);
|
||||
gboolean (* selection_request_event) (GtkWidget *widget,
|
||||
GdkEventSelection *event);
|
||||
gboolean (* selection_notify_event) (GtkWidget *widget,
|
||||
GdkEventSelection *event);
|
||||
gboolean (* proximity_in_event) (GtkWidget *widget,
|
||||
GdkEventProximity *event);
|
||||
gboolean (* proximity_out_event) (GtkWidget *widget,
|
||||
|
@ -7084,98 +7084,6 @@ selection_test_received (GtkWidget *tree_view,
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
selection_test_get_targets (GtkWidget *dialog, gint response, GtkWidget *tree_view)
|
||||
{
|
||||
static GdkAtom targets_atom = NULL;
|
||||
|
||||
if (response != GTK_RESPONSE_APPLY)
|
||||
{
|
||||
gtk_widget_destroy (dialog);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targets_atom == NULL)
|
||||
targets_atom = gdk_atom_intern ("TARGETS", FALSE);
|
||||
|
||||
gtk_selection_convert (tree_view, GDK_SELECTION_PRIMARY, targets_atom,
|
||||
GDK_CURRENT_TIME);
|
||||
}
|
||||
|
||||
void
|
||||
create_selection_test (GtkWidget *widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *content_area;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *scrolled_win;
|
||||
GtkListStore* store;
|
||||
GtkWidget *tree_view;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkWidget *label;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_dialog_new ();
|
||||
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
gtk_widget_get_display (widget));
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&window);
|
||||
|
||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Selection Test");
|
||||
|
||||
/* Create the list */
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||
gtk_box_pack_start (GTK_BOX (content_area), vbox);
|
||||
|
||||
label = gtk_label_new ("Gets available targets for current selection");
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label);
|
||||
|
||||
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scrolled_win);
|
||||
gtk_widget_set_size_request (scrolled_win, 100, 200);
|
||||
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_win), tree_view);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Target", renderer,
|
||||
"text", 0, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
||||
|
||||
g_signal_connect (tree_view, "selection_received",
|
||||
G_CALLBACK (selection_test_received), NULL);
|
||||
|
||||
/* .. And create some buttons */
|
||||
gtk_dialog_add_button (GTK_DIALOG (window),
|
||||
"Get Targets",
|
||||
GTK_RESPONSE_APPLY);
|
||||
|
||||
g_signal_connect (window, "response",
|
||||
G_CALLBACK (selection_test_get_targets), tree_view);
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (window),
|
||||
"Quit",
|
||||
GTK_RESPONSE_CLOSE);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test scrolling
|
||||
*/
|
||||
@ -8043,7 +7951,6 @@ struct {
|
||||
{ "statusbar", create_statusbar },
|
||||
{ "test mainloop", create_mainloop, TRUE },
|
||||
{ "test scrolling", create_scroll_test },
|
||||
{ "test selection", create_selection_test },
|
||||
{ "test timeout", create_timeout_test },
|
||||
{ "toggle buttons", create_toggle_buttons },
|
||||
{ "tooltips", create_tooltips },
|
||||
|
Loading…
Reference in New Issue
Block a user