Ejemplo n.º 1
0
static void
async_write_data_cb (GObject      *object,
                     GAsyncResult *res,
                     gpointer      user_data)
{
  AsyncWriteData *write_data = user_data;
  GError *error = NULL;
  gsize bytes_written;

  bytes_written = g_output_stream_write_finish (G_OUTPUT_STREAM (object),
                                                res, &error);
  if (error)
    {
      g_warning ("Error writing selection data: %s", error->message);
      g_error_free (error);

      async_write_data_free (write_data);
      return;
    }

  write_data->index += bytes_written;

  if (write_data->index <
      write_data->selection->stored_selection.data_len)
    {
      /* Write the next chunk */
      async_write_data_write (write_data);
    }
  else
    async_write_data_free (write_data);
}
Ejemplo n.º 2
0
static gboolean
gdk_wayland_selection_check_write (GdkWaylandSelection *selection)
{
  AsyncWriteData *write_data;

  if (selection->stored_selection.fd < 0 ||
      selection->stored_selection.data_len == 0)
    return FALSE;

  write_data = async_write_data_new (selection);
  async_write_data_write (write_data);
  selection->stored_selection.fd = -1;

  return TRUE;
}
Ejemplo n.º 3
0
static gboolean
gdk_wayland_selection_check_write (GdkWaylandSelection *selection)
{
  AsyncWriteData *write_data;

  if (selection->stored_selection.fd < 0)
    return FALSE;

  /* Cancel any previous ongoing async write */
  if (selection->stored_selection.cancellable)
    {
      g_cancellable_cancel (selection->stored_selection.cancellable);
      g_object_unref (selection->stored_selection.cancellable);
    }

  selection->stored_selection.cancellable = g_cancellable_new ();

  write_data = async_write_data_new (selection);
  async_write_data_write (write_data);
  selection->stored_selection.fd = -1;

  return TRUE;
}