本文整理汇总了C++中G_IS_FILE函数的典型用法代码示例。如果您正苦于以下问题:C++ G_IS_FILE函数的具体用法?C++ G_IS_FILE怎么用?C++ G_IS_FILE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_IS_FILE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ide_git_vcs_is_ignored
static gboolean
ide_git_vcs_is_ignored (IdeVcs *vcs,
GFile *file,
GError **error)
{
g_autofree gchar *name = NULL;
IdeGitVcs *self = (IdeGitVcs *)vcs;
gboolean ret = FALSE;
g_assert (IDE_IS_GIT_VCS (self));
g_assert (G_IS_FILE (file));
name = g_file_get_relative_path (self->working_directory, file);
if (g_strcmp0 (name, ".git") == 0)
return TRUE;
if (name != NULL)
return ggit_repository_path_is_ignored (self->repository, name, error);
return ret;
}
示例2: compare_to_file
static gboolean
compare_to_file (gconstpointer a,
gconstpointer b)
{
GFile *file = (GFile *)a;
GObject *item = (GObject *)b;
/*
* Our key (the GFile) is always @a.
* The potential match (maybe a GbProjectFile) is @b.
* @b may also be NULL.
*/
g_assert (G_IS_FILE (file));
g_assert (!item || G_IS_OBJECT (item));
if (GB_IS_PROJECT_FILE (item))
return g_file_equal (file, gb_project_file_get_file (GB_PROJECT_FILE (item)));
return FALSE;
}
示例3: ide_build_system_new_async
/**
* ide_build_system_new_async:
* @context: #IdeBuildSystem
* @project_file: A #GFile containing the directory or project file.
* @cancellable: (allow-none): A #GCancellable
* @callback: A callback to execute upon completion
* @user_data: User data for @callback.
*
* Asynchronously creates a new #IdeBuildSystem instance using the registered
* #GIOExtensionPoint system. Each extension point will be tried asynchronously
* by priority until one has been found that supports @project_file.
*
* If no build system could be found, then ide_build_system_new_finish() will
* return %NULL.
*/
void
ide_build_system_new_async (IdeContext *context,
GFile *project_file,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (IDE_IS_CONTEXT (context));
g_return_if_fail (G_IS_FILE (project_file));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
ide_object_new_for_extension_async (IDE_TYPE_BUILD_SYSTEM,
sort_priority, NULL,
G_PRIORITY_DEFAULT,
cancellable,
callback,
user_data,
"context", context,
"project-file", project_file,
NULL);
}
示例4: ide_project_files_find_file
/**
* ide_project_files_find_file:
* @self: (in): A #IdeProjectFiles.
* @file: A #GFile.
*
* Tries to locate an #IdeProjectFile matching the given file.
* If @file is the working directory, @self is returned.
*
* Returns: (transfer none) (nullable): An #IdeProjectItem or %NULL.
*/
IdeProjectItem *
ide_project_files_find_file (IdeProjectFiles *self,
GFile *file)
{
IdeProjectItem *item;
IdeContext *context;
IdeVcs *vcs;
GFile *workdir;
gchar **parts;
gchar *path;
gsize i;
g_return_val_if_fail (IDE_IS_PROJECT_FILES (self), NULL);
g_return_val_if_fail (G_IS_FILE (file), NULL);
item = IDE_PROJECT_ITEM (self);
context = ide_object_get_context (IDE_OBJECT (self));
vcs = ide_context_get_vcs (context);
workdir = ide_vcs_get_working_directory (vcs);
if (g_file_equal (workdir, file))
return IDE_PROJECT_ITEM (self);
path = g_file_get_relative_path (workdir, file);
if (path == NULL)
return NULL;
parts = g_strsplit (path, G_DIR_SEPARATOR_S, 0);
for (i = 0; parts [i]; i++)
{
if (!(item = ide_project_files_find_child (item, parts [i])))
break;
}
g_strfreev (parts);
g_free (path);
return item;
}
示例5: gimp_color_profile_combo_box_set_active_file
/**
* gimp_color_profile_combo_box_set_active_file:
* @combo: a #GimpColorProfileComboBox
* @file: file of the profile to select
* @label: label to use when adding a new entry (can be %NULL)
*
* Selects a color profile from the @combo and makes it the active
* item. If the profile is not listed in the @combo, then it is added
* with the given @label (or @file in case that @label is %NULL).
*
* Since: 2.10
**/
void
gimp_color_profile_combo_box_set_active_file (GimpColorProfileComboBox *combo,
GFile *file,
const gchar *label)
{
GimpColorProfile *profile = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
g_return_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo));
g_return_if_fail (file == NULL || G_IS_FILE (file));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
if (file && ! (label && *label))
{
GError *error = NULL;
profile = gimp_color_profile_new_from_file (file, &error);
if (! profile)
{
g_message ("%s", error->message);
g_clear_error (&error);
}
else
{
label = gimp_color_profile_get_label (profile);
}
}
if (_gimp_color_profile_store_history_add (GIMP_COLOR_PROFILE_STORE (model),
file, label, &iter))
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);
}
if (profile)
g_object_unref (profile);
}
示例6: gedit_recent_remove_if_local
void
gedit_recent_remove_if_local (GFile *location)
{
g_return_if_fail (G_IS_FILE (location));
/* If a file is local chances are that if load/save fails the file has
* beed removed and the failure is permanent so we remove it from the
* list of recent files. For remote files the failure may be just
* transitory and we keep the file in the list.
*/
if (g_file_has_uri_scheme (location, "file"))
{
GtkRecentManager *recent_manager;
gchar *uri;
recent_manager = gtk_recent_manager_get_default ();
uri = g_file_get_uri (location);
gtk_recent_manager_remove_item (recent_manager, uri, NULL);
g_free (uri);
}
}
示例7: gimp_config_serialize_to_gfile
/**
* gimp_config_serialize_to_gfile:
* @config: a #GObject that implements the #GimpConfigInterface.
* @file: the #GFile to write the configuration to.
* @header: optional file header (must be ASCII only)
* @footer: optional file footer (must be ASCII only)
* @data: user data passed to the serialize implementation.
* @error: return location for a possible error
*
* Serializes the object properties of @config to the file specified
* by @file. If a file with that name already exists, it is
* overwritten. Basically this function opens @file for you and calls
* the serialize function of the @config's #GimpConfigInterface.
*
* Return value: %TRUE if serialization succeeded, %FALSE otherwise.
*
* Since: 2.10
**/
gboolean
gimp_config_serialize_to_gfile (GimpConfig *config,
GFile *file,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error)
{
GimpConfigWriter *writer;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
writer = gimp_config_writer_new_gfile (file, TRUE, header, error);
if (!writer)
return FALSE;
GIMP_CONFIG_GET_INTERFACE (config)->serialize (config, writer, data);
return gimp_config_writer_finish (writer, footer, error);
}
示例8: photos_glib_file_create_async
void
photos_glib_file_create_async (GFile *file,
GFileCreateFlags flags,
gint io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_autoptr (GTask) task = NULL;
g_autoptr (PhotosGLibFileCreateData) data = NULL;
g_return_if_fail (G_IS_FILE (file));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
task = g_task_new (file, cancellable, callback, user_data);
g_task_set_source_tag (task, photos_glib_file_create_async);
data = photos_glib_file_create_data_new (file, flags, io_priority);
g_task_set_task_data (task, g_steal_pointer (&data), (GDestroyNotify) photos_glib_file_create_data_free);
g_file_create_async (file, flags, io_priority, cancellable, photos_glib_file_create_create, g_object_ref (task));
}
示例9: gtk_hotkey_key_file_registry_real_has_hotkey
static gboolean
gtk_hotkey_key_file_registry_real_has_hotkey (GtkHotkeyRegistry *base,
const gchar *app_id,
const gchar *key_id)
{
GFile *file;
gboolean exists;
g_return_val_if_fail (app_id != NULL, FALSE);
g_return_val_if_fail (key_id != NULL, FALSE);
file = get_hotkey_file (app_id);
g_return_val_if_fail (G_IS_FILE(file), FALSE);
if (g_file_query_exists (file, NULL))
exists = TRUE;
else
exists = FALSE;
g_object_unref (file);
return exists;
}
示例10: empathy_tp_file_offer
/**
* empathy_tp_file_offer:
* @self: an outgoing #EmpathyTpFile
* @gfile: the source #GFile for the transfer
* @cancellable: a #GCancellable
* @progress_callback: function to callback with progress information
* @progress_user_data: user_data to pass to @progress_callback
* @op_callback: function to callback when the transfer ends
* @op_user_data: user_data to pass to @op_callback
*
* Offers an outgoing file transfer, reading data from @gfile.
* The callback @op_callback will be called both when the transfer is
* successful and in case of an error. Note that cancelling @cancellable,
* closes the socket of the file operation in progress, but doesn't
* guarantee that the transfer channel will be closed as well. Thus,
* empathy_tp_file_cancel() or empathy_tp_file_close() should be used to
* actually cancel an ongoing #EmpathyTpFile.
*/
void
empathy_tp_file_offer (EmpathyTpFile *self,
GFile *gfile,
GCancellable *cancellable,
EmpathyTpFileProgressCallback progress_callback,
gpointer progress_user_data,
EmpathyTpFileOperationCallback op_callback,
gpointer op_user_data)
{
g_return_if_fail (EMPATHY_IS_TP_FILE (self));
g_return_if_fail (G_IS_FILE (gfile));
g_return_if_fail (G_IS_CANCELLABLE (cancellable));
self->priv->cancellable = g_object_ref (cancellable);
self->priv->progress_callback = progress_callback;
self->priv->progress_user_data = progress_user_data;
self->priv->op_callback = op_callback;
self->priv->op_user_data = op_user_data;
g_file_read_async (gfile, G_PRIORITY_DEFAULT, cancellable,
file_read_async_cb, self);
}
示例11: empathy_ft_handler_incoming_set_destination
/**
* empathy_ft_handler_incoming_set_destination:
* @handler: an #EmpathyFTHandler
* @destination: the #GFile where the transfer should be saved
*
* Sets the destination of the incoming handler to be @destination.
* Note that calling this method is mandatory before starting the transfer
* for incoming handlers.
*/
void
empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler,
GFile *destination)
{
EmpathyFTHandlerPriv *priv;
g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
g_return_if_fail (G_IS_FILE (destination));
priv = GET_PRIV (handler);
g_object_set (handler, "gfile", destination, NULL);
/* check if hash is supported. if it isn't, set use_hash to FALSE
* anyway, so that clients won't be expecting us to checksum.
*/
if (EMP_STR_EMPTY (priv->content_hash) ||
priv->content_hash_type == TP_FILE_HASH_TYPE_NONE)
priv->use_hash = FALSE;
else
priv->use_hash = TRUE;
}
示例12: what_failed_on_file_operation_failure
/*
* what_failed_on_file_operation_failure:
* @file: the file reference that failed.
* @transient: %TRUE if this failure is likely to be permanent, i.e. a malformed
* path. %FALSE if the action might succeed on subsequent attempts.
* @what: indicates whether it was an open, save, or other operation that
* failed.
*
* Helper function that picks a suitable error message describing what failed.
* Based on code from Conglomerate.
*
* Returns: (transfer full): a newly-allocated string.
*/
static char *
what_failed_on_file_operation_failure(GFile *file, gboolean transient, I7FileErrorWhat what)
{
char *displayname, *what_failed, *path;
GFile *parent;
g_return_val_if_fail(file || G_IS_FILE(file), NULL);
displayname = file_get_display_name(file);
parent = g_file_get_parent(file);
path = g_file_get_path(parent);
g_object_unref(parent);
if(what == I7_FILE_ERROR_OTHER) {
/* Generic file error */
what_failed = g_strdup_printf(_("Inform got an error while accessing \"%s\" from %s."), displayname, path);
} else if(transient) {
/* A "what failed" message when the failure is likely to be
permanent; this URI won't be accessible */
if(what == I7_FILE_ERROR_OPEN)
what_failed = g_strdup_printf(_("Inform cannot read \"%s\" from %s."), displayname, path);
else
what_failed = g_strdup_printf(_("Inform cannot save \"%s\" to %s."), displayname, path);
} else {
/* A "what failed" message when the failure is likely to be
transient; this URI might be accessible on subsequent attempts, or
with some troubleshooting. */
if(what == I7_FILE_ERROR_OPEN)
what_failed = g_strdup_printf(_("Inform could not read \"%s\" from %s."), displayname, path);
else
what_failed = g_strdup_printf(_("Inform could not save \"%s\" to %s."), displayname, path);
}
g_free(path);
g_free(displayname);
return what_failed;
}
示例13: photos_glib_file_copy_create
static void
photos_glib_file_copy_create (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GCancellable *cancellable;
g_autoptr (GFile) unique_file = NULL;
GFile *destination = G_FILE (source_object);
GFile *source;
g_autoptr (GFileOutputStream) ostream = NULL;
g_autoptr (GTask) task = G_TASK (user_data);
PhotosGLibFileCopyData *data;
cancellable = g_task_get_cancellable (task);
data = (PhotosGLibFileCopyData *) g_task_get_task_data (task);
source = G_FILE (g_task_get_source_object (task));
{
g_autoptr (GError) error = NULL;
ostream = photos_glib_file_create_finish (destination, res, &unique_file, &error);
if (error != NULL)
{
g_task_return_error (task, g_steal_pointer (&error));
goto out;
}
}
g_assert_null (data->ostream);
g_assert_true (G_IS_FILE_OUTPUT_STREAM (ostream));
data->ostream = g_object_ref (ostream);
g_assert_null (data->unique_file);
g_assert_true (G_IS_FILE (unique_file));
data->unique_file = g_object_ref (unique_file);
g_file_read_async (source, data->io_priority, cancellable, photos_glib_file_copy_read, g_object_ref (task));
out:
return;
}
示例14: xml_reader_load_from_file
gboolean
xml_reader_load_from_file (XmlReader *reader,
GFile *file,
GCancellable *cancellable,
GError **error)
{
GFileInputStream *stream;
gboolean ret;
g_return_val_if_fail (XML_IS_READER (reader), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
if (!(stream = g_file_read (file, cancellable, error)))
return FALSE;
ret = xml_reader_load_from_stream (reader, G_INPUT_STREAM (stream), error);
g_clear_object (&stream);
return ret;
}
示例15: gimp_pattern_load_pixbuf
GList *
gimp_pattern_load_pixbuf (GimpContext *context,
GFile *file,
GInputStream *input,
GError **error)
{
GimpPattern *pattern;
GdkPixbuf *pixbuf;
gchar *name;
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
pixbuf = gdk_pixbuf_new_from_stream (input, NULL, error);
if (! pixbuf)
return NULL;
name = g_strdup (gdk_pixbuf_get_option (pixbuf, "tEXt::Title"));
if (! name)
name = g_strdup (gdk_pixbuf_get_option (pixbuf, "tEXt::Comment"));
if (! name)
name = g_path_get_basename (gimp_file_get_utf8_name (file));
pattern = g_object_new (GIMP_TYPE_PATTERN,
"name", name,
"mime-type", NULL, /* FIXME!! */
NULL);
g_free (name);
pattern->mask = gimp_temp_buf_new_from_pixbuf (pixbuf, NULL);
g_object_unref (pixbuf);
return g_list_prepend (NULL, pattern);
}