void
pp_maintenance_command_is_supported_async  (PpMaintenanceCommand *command,
                                            GCancellable         *cancellable,
                                            GAsyncReadyCallback   callback,
                                            gpointer              user_data)
{
  GTask *task;

  task = g_task_new (command, cancellable, callback, user_data);
  g_task_set_check_cancellable (task, TRUE);
  g_task_run_in_thread (task, _pp_maintenance_command_is_supported_thread);

  g_object_unref (task);
}
Esempio n. 2
0
static void
photos_base_item_create_thumbnail_async (PhotosBaseItem *self,
                                         GCancellable *cancellable,
                                         GAsyncReadyCallback callback,
                                         gpointer user_data)
{
  GTask *task;

  task = g_task_new (self, cancellable, callback, user_data);
  g_task_set_check_cancellable (task, TRUE);
  g_task_set_source_tag (task, photos_base_item_create_thumbnail_async);

  g_thread_pool_push (create_thumbnail_pool, g_object_ref (task), NULL);
  g_object_unref (task);
}
void
ide_application_open_async (IdeApplication       *self,
                            GFile               **files,
                            gint                  n_files,
                            const gchar          *hint,
                            GCancellable         *cancellable,
                            GAsyncReadyCallback   callback,
                            gpointer              user_data)
{
  g_autoptr(GTask) task = NULL;
  g_autoptr(GPtrArray) ar = NULL;
  IdeApplicationOpen *state;
  guint i;

  g_return_if_fail (IDE_IS_APPLICATION (self));
  g_return_if_fail (!n_files || files != NULL);
  g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));

  task = g_task_new (self, cancellable, callback, user_data);
  g_task_set_source_tag (task, ide_application_open_async);
  g_task_set_check_cancellable (task, FALSE);

  /*
   * We have to open each file one at a time so that we don't race to
   * open the same containing project multiple times.
   */

  ar = g_ptr_array_new_with_free_func (g_object_unref);

  for (i = 0; i < n_files; i++)
    {
      GFile *file = files [i];

      if (!maybe_open_with_existing_workspace (self, file, hint, cancellable))
        g_ptr_array_add (ar, g_object_ref (file));
    }

  state = g_slice_new0 (IdeApplicationOpen);
  state->hint = g_strdup (hint);
  state->files = g_steal_pointer (&ar);

  g_task_set_task_data (task, state, ide_application_open_free);
  ide_application_open_tick (task);
}
Esempio n. 4
0
void
um_realm_login (UmRealmObject *realm,
                const gchar *user,
                const gchar *password,
                GCancellable *cancellable,
                GAsyncReadyCallback callback,
                gpointer user_data)
{
        GTask *task;
        LoginClosure *login;
        UmRealmKerberos *kerberos;

        g_return_if_fail (UM_REALM_IS_OBJECT (realm));
        g_return_if_fail (user != NULL);
        g_return_if_fail (password != NULL);
        g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));

        kerberos = um_realm_object_get_kerberos (realm);
        g_return_if_fail (kerberos != NULL);

        task = g_task_new (realm, cancellable, callback, user_data);
        login = g_slice_new0 (LoginClosure);
        login->domain = g_strdup (um_realm_kerberos_get_domain_name (kerberos));
        login->realm = g_strdup (um_realm_kerberos_get_realm_name (kerberos));
        login->user = g_strdup (user);
        login->password = g_strdup (password);
        g_task_set_task_data (task, login, login_closure_free);

        g_task_set_check_cancellable (task, TRUE);
        g_task_set_return_on_cancel (task, TRUE);

        g_task_run_in_thread (task, kinit_thread_func);

        g_object_unref (task);
        g_object_unref (kerberos);
}