当前位置: 首页>>代码示例>>C++>>正文


C++ G_FILE函数代码示例

本文整理汇总了C++中G_FILE函数的典型用法代码示例。如果您正苦于以下问题:C++ G_FILE函数的具体用法?C++ G_FILE怎么用?C++ G_FILE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了G_FILE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: add_file_to_dialog

static void
add_file_to_dialog (gpointer data, gpointer user_data)
{
	CopyThemeDialogPrivate *priv;
	GFile *file;
	gchar *basename = NULL, *raw_basename;

	priv = COPY_THEME_DIALOG (user_data)->priv;
	file = G_FILE (data);

	raw_basename = g_file_get_basename (file);
	if (g_str_has_suffix (raw_basename, ".desktop"))
	{
		/* FIXME: validate key file? */
		basename = g_strndup (raw_basename,
		                      /* 8 = strlen (".desktop") */
		                      strlen (raw_basename) - 8);
	}
	g_free (raw_basename);

	if (basename)
	{
		g_object_ref (file);
		priv->all_files = g_slist_append (priv->all_files, file);
		priv->all_basenames = g_slist_append (priv->all_basenames, basename);
		priv->total_files++;
	}

	else
	{
		GtkWidget *dialog;
		gchar *uri;

		dialog = gtk_message_dialog_new (GTK_WINDOW (user_data),
		                                 GTK_DIALOG_MODAL,
		                                 GTK_MESSAGE_ERROR,
		                                 GTK_BUTTONS_OK,
		                                 _("Invalid screensaver theme"));
		uri = g_file_get_uri (file);
		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
		        _("%s does not appear to be a valid screensaver theme."),
		        uri);
		g_free (uri);
		gtk_window_set_title (GTK_WINDOW (dialog), "");
		gtk_window_set_icon_name (GTK_WINDOW (dialog), "preferences-desktop-screensaver");

		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
	}
}
开发者ID:bk2204,项目名称:mate-screensaver,代码行数:50,代码来源:copy-theme-dialog.c

示例2: on_file_replace_ready

static void on_file_replace_ready (GObject *object, GAsyncResult *res, gpointer data)
{
	GError *error = NULL;
	GDownloadable *download = G_DOWNLOADABLE (data);
	GioDownload *gio_download = GIO_DOWNLOAD (data);
	g_assert (download != NULL);

	gio_download->priv->output = g_file_replace_finish (G_FILE(object), res, &error);
	//	GFileOutputStream *out_stream = g_file_replace_finish (G_FILE(object), res, &error);
	//	gio_download->priv->output	  = g_buffered_output_stream_new_sized (G_OUTPUT_STREAM(out_stream),
	//																	CHUNK_BUFF_SIZE);
	handle_critical_error (error);
	read_input_stream (download);
}
开发者ID:trhura,项目名称:rookie,代码行数:14,代码来源:gio-download.c

示例3: fr_file_selector_dialog_set_selected_files

void
fr_file_selector_dialog_set_selected_files (FrFileSelectorDialog  *self,
					    GList                 *files)
{
	GFile *folder;

	if (files == NULL)
		return;

	folder = g_file_get_parent (G_FILE (files->data));
	_set_current_folder (self, folder, files);

	g_object_unref (folder);
}
开发者ID:UIKit0,项目名称:file-roller,代码行数:14,代码来源:fr-file-selector-dialog.c

示例4: photos_thumbnailer_generate_thumbnail_replace

static void
photos_thumbnailer_generate_thumbnail_replace (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  GCancellable *cancellable;
  GFile *thumbnail_file = G_FILE (source_object);
  g_autoptr (GFileOutputStream) stream = NULL;
  g_autoptr (GTask) task = G_TASK (user_data);
  PhotosThumbnailerGenerateData *data;
  const gchar *prgname;
  g_autofree gchar *original_height_str = NULL;
  g_autofree gchar *original_width_str = NULL;
  g_autofree gchar *uri = NULL;

  cancellable = g_task_get_cancellable (task);
  data = g_task_get_task_data (task);

  {
    g_autoptr (GError) error = NULL;

    stream = g_file_replace_finish (thumbnail_file, res, &error);
    if (error != NULL)
      {
        g_task_return_error (task, g_steal_pointer (&error));
        goto out;
      }
  }

  g_assert_null (data->stream);
  data->stream = g_object_ref (stream);

  original_height_str = g_strdup_printf ("%" G_GINT64_FORMAT, data->original_height);
  original_width_str = g_strdup_printf ("%" G_GINT64_FORMAT, data->original_width);
  prgname = g_get_prgname ();
  uri = g_file_get_uri (data->file);
  gdk_pixbuf_save_to_stream_async (data->pixbuf_thumbnail,
                                   G_OUTPUT_STREAM (stream),
                                   "png",
                                   cancellable,
                                   photos_thumbnailer_generate_thumbnail_save_to_stream,
                                   g_object_ref (task),
                                   "tEXt::Software", prgname,
                                   "tEXt::Thumb::URI", uri,
                                   "tEXt::Thumb::Image::Height", original_height_str,
                                   "tEXt::Thumb::Image::Width", original_width_str,
                                   NULL);

 out:
  return;
}
开发者ID:GNOME,项目名称:gnome-photos,代码行数:49,代码来源:photos-thumbnailer.c

示例5: async_ready_func

static void
async_ready_func (GObject      *source,
                  GAsyncResult *result,
                  gpointer      user_data)
{
  const gchar *filename = user_data;
  GError *error = NULL;
  guint64 disk_usage;
  guint64 num_dirs;
  guint64 num_files;

  g_file_measure_disk_usage_finish (G_FILE (source), result, &disk_usage, &num_dirs, &num_files, &error);
  print_result (filename, disk_usage, num_dirs, num_files, error, '\n');
  outstanding_asyncs--;
}
开发者ID:ebassi,项目名称:glib,代码行数:15,代码来源:gio-du.c

示例6: g_file_copy_async_finish_handler

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);
}
开发者ID:PeterDaveHello,项目名称:deepin-installer,代码行数:15,代码来源:fileops.c

示例7: create_thumbnail

static void
create_thumbnail (GTask *task,
                  gpointer source_object,
                  gpointer task_data,
                  GCancellable *cancellable)
{
  GFile *file = G_FILE (source_object);
  GnomeDesktopThumbnailFactory *factory = NULL;
  GError *error = NULL;
  GFileInfo *info = NULL;
  gchar *uri = NULL;
  GdkPixbuf *pixbuf = NULL;
  guint64 mtime;

  uri = g_file_get_uri (file);

  info = g_file_query_info (file, ATTRIBUTES_FOR_THUMBNAIL,
                            G_FILE_QUERY_INFO_NONE,
                            NULL, &error);

  if (info == NULL)
    {
      g_task_return_error (task, error);
      goto out;
    }

  mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);

  factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
  pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail
    (factory, 
     uri, g_file_info_get_content_type (info));

  if (pixbuf == NULL)
    {
      g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "GnomeDesktopThumbnailFactory failed");
      goto out;
    }

  gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime);
  g_task_return_boolean (task, TRUE);

 out:
  g_clear_object (&info);
  g_clear_object (&factory);
  g_clear_object (&pixbuf);
  g_free (uri);
}
开发者ID:GNOME,项目名称:gnome-documents,代码行数:48,代码来源:gd-utils.c

示例8: copy_finished_cb

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;

  if (!g_file_copy_finish (G_FILE (source_object), result, &err))
    {
      if (err->code != G_IO_ERROR_CANCELLED)
        g_warning ("Failed to copy image to cache location: %s", err->message);

      g_error_free (err);
    }
  item = g_object_get_data (source_object, "item");

  g_settings_apply (priv->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 (priv->current_background)
    cc_background_item_load (priv->current_background, NULL);

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

      update_preview (priv, item);

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

  /* remove the reference taken when the copy was set up */
  g_object_unref (panel);
}
开发者ID:tigersoldier,项目名称:gnome-control-center,代码行数:48,代码来源:cc-background-panel.c

示例9: on_size_query_ready

static void on_size_query_ready (GObject * object, GAsyncResult * result, gpointer data)
{
	GError *error = NULL;
	GFileInfo *info = g_file_query_info_finish (G_FILE(object), result, &error);
	GDownloadable *download = G_DOWNLOADABLE(data);
	g_assert (download != NULL);
	
	if (error) {
		handle_error (error);
		g_downloadable_set_status (download, G_DOWNLOADABLE_NETWORK_ERROR);
		
	} else {
		download->priv->size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
		g_object_unref (info);
	}
}
开发者ID:trhura,项目名称:rookie,代码行数:16,代码来源:gio-download.c

示例10: on_replace_file_ready

static void
on_replace_file_ready (GObject *source, GAsyncResult *res, gpointer user_data)
{
	GcrCertificateExporter *self = GCR_CERTIFICATE_EXPORTER (user_data);
	GFile *file = G_FILE (source);
	GFileOutputStream *os;

	os = g_file_replace_finish (file, res, &self->pv->error);

	if (self->pv->error) {
		complete_async_result (self);
		return;
	}

	write_to_outputstream (self, G_OUTPUT_STREAM (os));
}
开发者ID:Distrotech,项目名称:gcr,代码行数:16,代码来源:gcr-certificate-exporter.c

示例11: info

void TrashLauncherIcon::UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data)
{
  auto self = static_cast<TrashLauncherIcon*>(data);

  // FIXME: should use the generic LoadIcon function (not taking from the unity theme)
  glib::Object<GFileInfo> info(g_file_query_info_finish(G_FILE(source), res, nullptr));

  if (info)
  {
    glib::Object<GIcon> icon(g_file_info_get_icon(info), glib::AddRef());
    glib::String icon_string(g_icon_to_string(icon));

    self->icon_name = icon_string.Str();
    self->empty_ = (self->icon_name == "user-trash");
  }
}
开发者ID:jonjahren,项目名称:unity,代码行数:16,代码来源:TrashLauncherIcon.cpp

示例12: copy_wallpaper_ready_cb

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);
}
开发者ID:JosephMcc,项目名称:pix,代码行数:17,代码来源:actions.c

示例13: find_file_insensitive_exists_callback

static void
find_file_insensitive_exists_callback (GObject *source_object,
                                       GAsyncResult *res,
                                       gpointer user_data)
{
  GFileInfo *info;
  InsensitiveFileSearchData *data = (InsensitiveFileSearchData *) (user_data);

  /* The file exists and can be found with the given path, no need to search. */
  if ((info = g_file_query_info_finish (G_FILE (source_object), res, NULL)))
    {
      GSimpleAsyncResult *simple;

      simple = g_simple_async_result_new (G_OBJECT (data->root),
                                          data->callback,
                                          data->user_data,
                                          _g_find_file_insensitive_async);

      g_simple_async_result_set_op_res_gpointer (simple, g_object_ref (source_object), g_object_unref);
      g_simple_async_result_complete_in_idle (simple);
      g_object_unref (simple);
      clear_find_file_insensitive_state (data);
      g_object_unref (info);
    }

  else
    {
      data->split_path = g_strsplit (data->original_path, G_DIR_SEPARATOR_S, -1);
      data->index = 0;
      data->enumerator = NULL;
      data->current_file = g_object_ref (data->root);

      /* Skip any empty components due to multiple slashes */
      while (data->split_path[data->index] != NULL &&
             *data->split_path[data->index] == 0)
        data->index++;

      g_file_enumerate_children_async (data->current_file,
                                       G_FILE_ATTRIBUTE_STANDARD_NAME,
                                       0, G_PRIORITY_DEFAULT,
                                       data->cancellable,
                                       enumerated_children_callback, data);
    }

  g_object_unref (source_object);
}
开发者ID:DarkProfit,项目名称:gvfs,代码行数:46,代码来源:gvfsmountinfo.c

示例14: remote_file_copy_cb

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);
}
开发者ID:TiredFingers,项目名称:gnome-documents,代码行数:17,代码来源:gd-pdf-loader.c

示例15: message_handler

static gboolean
message_handler (GstBus * bus, GstMessage * message, gpointer user_data)
{
  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ELEMENT:{
      const GstStructure *s = gst_message_get_structure (message);
      const gchar *name = gst_structure_get_name (s);

      if (strcmp (name, "not-mounted") == 0) {
        GMountOperation *mop = gtk_mount_operation_new (NULL);
        GFile *file =
            G_FILE (g_value_get_object (gst_structure_get_value (s, "file")));

        g_print ("not-mounted\n");
        gst_element_set_state (pipeline, GST_STATE_NULL);
        gst_bus_set_flushing (bus, TRUE);

        g_file_mount_enclosing_volume (file, G_MOUNT_MOUNT_NONE,
            mop, NULL, mount_cb, bus);

        g_object_unref (mop);
      }
      break;
    }

    case GST_MESSAGE_EOS:
      g_print ("EOS\n");
      gtk_main_quit ();
      break;
    case GST_MESSAGE_ERROR:{
      GError *err = NULL;

      gst_message_parse_error (message, &err, NULL);
      g_print ("error: %s\n", err->message);
      g_clear_error (&err);

      gtk_main_quit ();
      break;
    }
    default:
      break;
  }

  return TRUE;
}
开发者ID:ConfusedReality,项目名称:pkg_multimedia_gst-plugins-base,代码行数:45,代码来源:giosrc-mounting.c


注:本文中的G_FILE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。