static void
copy_finished_cb (GObject      *source_object,
                  GAsyncResult *result,
                  gpointer      pointer)
{
  GError *err = NULL;
  CcBackgroundPanel *panel = (CcBackgroundPanel *) pointer;
  CcBackgroundPanelPrivate *priv = panel->priv;
  CcBackgroundItem *item;
  CcBackgroundItem *current_background;
  GSettings *settings;

  if (!g_file_copy_finish (G_FILE (source_object), result, &err))
    {
      if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
        g_error_free (err);
        return;
      }
      g_warning ("Failed to copy image to cache location: %s", err->message);
      g_error_free (err);
    }
  item = g_object_get_data (source_object, "item");
  settings = g_object_get_data (source_object, "settings");
  current_background = CURRENT_BG;

  g_settings_apply (settings);

  /* the panel may have been destroyed before the callback is run, so be sure
   * to check the widgets are not NULL */

  if (priv->spinner)
    {
      gtk_widget_destroy (GTK_WIDGET (priv->spinner));
      priv->spinner = NULL;
    }

  if (current_background)
    cc_background_item_load (current_background, NULL);

  if (priv->builder)
    {
      char *filename;

      update_preview (priv, settings, item);
      current_background = CURRENT_BG;

      /* Save the source XML if there is one */
      filename = get_save_path (SAVE_PATH);
      if (create_save_dir ())
        cc_background_xml_save (current_background, filename);
    }

  /* remove the reference taken when the copy was set up */
  g_object_unref (panel);
}
static void
copy_cb (GObject *src, GAsyncResult *res, gpointer data)
{
	RBAsyncCopy *copy = RB_ASYNC_COPY (data);
	gboolean result;

	result = g_file_copy_finish (G_FILE (src), res, &copy->priv->error);

	rb_debug ("copy finished: %s", (result == FALSE) ? copy->priv->error->message : "ok");
	copy->priv->callback (copy, result, copy->priv->callback_data);
}
Ejemplo n.º 3
0
static void g_file_copy_async_finish_handler(GObject *source_object,
            GAsyncResult *res, gpointer user_data)
{
    GtkProgressBar *progress_bar = GTK_PROGRESS_BAR(user_data);
    COPY_ASYNC_FINISH =  g_file_copy_finish(G_FILE(source_object), res, NULL);

    gtk_progress_bar_set_show_text(progress_bar,TRUE);
    gtk_progress_bar_set_text(progress_bar, "Finished");
    gtk_progress_bar_set_fraction(progress_bar, 1.0);
    g_debug("_copy_files_async_true Finished");

    GtkWidget *parent = gtk_widget_get_parent((GtkWidget *)progress_bar);
    gtk_widget_destroy((GtkWidget *)progress_bar);
    gtk_widget_destroy(parent);
}
Ejemplo n.º 4
0
static void
copy_wallpaper_ready_cb (GObject      *source_object,
			 GAsyncResult *res,
			 gpointer      user_data)
{
	WallpaperData *wdata = user_data;
	GError        *error = NULL;

	if (! g_file_copy_finish (G_FILE (source_object), res, &error)) {
		_gtk_error_dialog_from_gerror_run (GTK_WINDOW (wdata->browser), _("Could not set the desktop background"), error);
		g_clear_error (&error);
		wallpaper_data_free (wdata);
		return;
	}

	wallpaper_data_set (wdata);
}
Ejemplo n.º 5
0
static void
remote_file_copy_cb (GObject *source,
                     GAsyncResult *res,
                     gpointer user_data)
{
  PdfLoadJob *job = user_data;
  GError *error = NULL;
  char *uri;

  g_file_copy_finish (G_FILE (source), res, &error);
  if (error != NULL) {
    pdf_load_job_complete_error (job, error);
    return;
  }

  pdf_load_job_cache_set_attributes (job);
}
Ejemplo n.º 6
0
static void
font_install_finished_cb (GObject      *source_object,
                          GAsyncResult *res,
                          gpointer      data)
{
    GError *err = NULL;

    g_file_copy_finish (G_FILE (source_object), res, &err);

    if (!err) {
        gtk_button_set_label (GTK_BUTTON (data), _("Installed"));
    }
    else {
        gtk_button_set_label (GTK_BUTTON (data), _("Install Failed"));
        g_debug ("Install failed: %s", err->message);
        g_error_free (err);
    }
    gtk_widget_set_sensitive (GTK_WIDGET (data), FALSE);
}
static void
picture_copied_for_read (GObject *source_object,
                         GAsyncResult *res,
                         gpointer user_data)
{
  BgPicturesSource *bg_source;
  CcBackgroundItem *item;
  GError *error = NULL;
  GFile *thumbnail_file = G_FILE (source_object);
  GFile *native_file;

  if (!g_file_copy_finish (thumbnail_file, res, &error))
    {
      if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        goto out;
      else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
        {
          gchar *uri;

          uri = g_file_get_uri (thumbnail_file);
          g_warning ("Failed to download '%s': %s", uri, error->message);
          g_free (uri);
          goto out;
        }
    }

  bg_source = BG_PICTURES_SOURCE (user_data);

  native_file = g_object_get_data (G_OBJECT (thumbnail_file), "native-file");
  item = g_object_get_data (G_OBJECT (thumbnail_file), "item");
  g_object_set_data_full (G_OBJECT (native_file), "item", g_object_ref (item), g_object_unref);
  g_file_read_async (native_file,
                     G_PRIORITY_DEFAULT,
                     bg_source->priv->cancellable,
                     picture_opened_for_read,
                     bg_source);

 out:
  g_clear_error (&error);
}
Ejemplo n.º 8
0
 void copy_async_lcb(GObject *source_object,GAsyncResult *res,gpointer user_data) {
 Tcopyfile *cf = user_data;
 gboolean done;
 GError *error=NULL;
 /* fill in the blanks */
 done = g_file_copy_finish(cf->curfile,res,&error);
 if (!done) {
    if (error->code == G_IO_ERROR_EXISTS) {
      gint retval;
      gchar *tmpstr, *dispname;
      GFileInfo *info =g_file_query_info (cf->curfile,"standard::display-name", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,NULL,NULL);
      dispname = (gchar *)g_file_info_get_display_name (info);
      tmpstr = g_strdup_printf(_("%s cannot be copied, it already exists, overwrite?"),dispname);
      retval = yes_no_dialog (_("Overwrite file?"), tmpstr);
      g_free(tmpstr);
      g_free(dispname);
      if (retval != -8) {
        g_file_copy_async(cf->curfile,cf->curdest,G_FILE_COPY_OVERWRITE,
            G_PRIORITY_LOW,NULL,
            NULL,NULL,
            copy_async_lcb,cf);
        return;
      }
    }else {
      g_print("ERROR copying file::%s\n",error->message);
      g_error_free (error);
    }
  }
  g_object_unref(cf->curfile);
  g_object_unref(cf->curdest);
  if (!copy_uris_process_queue(cf)) {
    filebrowser_backend_refresh_folder (cf->fbback);
    g_object_unref(cf->destdir);
    g_slice_free(Tcopyfile,cf);
  }
}
Ejemplo n.º 9
0
static void
single_copy_complete (GObject *source_object, GAsyncResult *res,
                      gpointer user_data)
{
	GError *error = NULL;
	gboolean should_continue = FALSE;
	CopyThemeDialog *dialog = COPY_THEME_DIALOG (user_data);

	if (g_file_copy_finish (G_FILE (source_object), res, &error))
	{
		should_continue = TRUE;
	}

	else
	{
		/* If the file already exists, generate a new random name
		 * and try again.
		**/
		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
		{
			GFile *file, *destination;
			gchar *basename, *full_basename;
			g_error_free (error);

			file = G_FILE (dialog->priv->file->data);
			basename = (gchar *) (dialog->priv->basename->data);

			g_return_if_fail (file != NULL);
			g_return_if_fail (basename != NULL);

			full_basename = g_strdup_printf ("%s-%u.desktop",
			                                 basename,
			                                 g_random_int ());
			destination = g_file_get_child (dialog->priv->theme_dir,
			                                full_basename);
			g_free (full_basename);

			g_file_copy_async (file, destination, G_FILE_COPY_NONE,
			                   G_PRIORITY_DEFAULT,
			                   dialog->priv->cancellable,
			                   NULL, NULL,
			                   single_copy_complete, dialog);
		}

		else
		{
			if (g_error_matches (error, G_IO_ERROR,
			                     G_IO_ERROR_CANCELLED))
			{
				/* User has cancelled the theme copy */
				g_signal_emit (G_OBJECT (dialog),
				               signals[CANCELLED],
				               0, NULL);
			}

			else
			{
				/* Some other error occurred, ignore and
				 * try to copy remaining files
				**/
				should_continue = TRUE;
			}

			g_error_free (error);
		}
	}

	/* Update informational widgets and, if needed, signal
	 * copy completion.
	**/
	if (should_continue)
	{
		dialog->priv->index++;
		dialog->priv->file = dialog->priv->file->next;
		dialog->priv->basename = dialog->priv->basename->next;
		copy_theme_dialog_update_num_files (dialog);
		copy_theme_dialog_copy_next (dialog);
	}
}