本文整理汇总了C++中G_MOUNT函数的典型用法代码示例。如果您正苦于以下问题:C++ G_MOUNT函数的具体用法?C++ G_MOUNT怎么用?C++ G_MOUNT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_MOUNT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eject_done_cb
static void
eject_done_cb (GObject *object,
GAsyncResult *res,
gpointer user_data)
{
gboolean succeeded;
GError *error = NULL;
GFile *file = G_FILE (user_data);
succeeded = g_mount_eject_with_operation_finish (G_MOUNT (object), res, &error);
g_object_unref (G_MOUNT (object));
if (!succeeded)
{
print_file_error (file, error->message);
success = FALSE;
g_error_free (error);
}
g_object_unref (file);
outstanding_mounts--;
if (outstanding_mounts == 0)
g_main_loop_quit (main_loop);
}
示例2: _vfs_backend_mount_callback
static void _vfs_backend_mount_callback (gpointer pObject, GAsyncResult *res, gpointer *data)
//static void _vfs_backend_mount_callback (gboolean succeeded, char *error, char *detailed_error, gpointer *data)
{
cd_message ("%s (%d)", __func__, GPOINTER_TO_INT (data[1]));
CairoDockFMMountCallback pCallback = data[0];
GError *erreur = NULL;
gboolean bSuccess;
if (GPOINTER_TO_INT (data[1]) == 1)
bSuccess = (g_file_mount_mountable_finish (G_FILE (pObject), res, &erreur) != NULL);
//bSuccess = (g_volume_mount_finish (G_VOLUME (pObject), res, &erreur));
else if (GPOINTER_TO_INT (data[1]) == 0)
bSuccess = g_mount_unmount_finish (G_MOUNT (pObject), res, &erreur);
else
bSuccess = g_mount_eject_finish (G_MOUNT (pObject), res, &erreur);
if (erreur != NULL)
{
cd_warning ("Attention : %s", erreur->message);
g_error_free (erreur);
}
cd_message ("(un)mount fini -> %d", bSuccess);
pCallback (GPOINTER_TO_INT (data[1]) == 1, bSuccess, data[2], data[3], data[4]);
//g_free (data[2]);
//g_object_unref (pObject);
//g_free (data);
}
示例3: unmount_mount_callback
static void
unmount_mount_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
char *primary;
gboolean unmounted;
gboolean should_eject;
GtkWidget *dialog;
should_eject = user_data != NULL;
error = NULL;
if (should_eject) {
unmounted = g_mount_eject_with_operation_finish (G_MOUNT (source_object),
res, &error);
} else {
unmounted = g_mount_unmount_with_operation_finish (G_MOUNT (source_object),
res, &error);
}
if (! unmounted) {
if (error->code != G_IO_ERROR_FAILED_HANDLED) {
if (should_eject) {
primary = g_strdup_printf (_("Unable to eject %p"), source_object);
} else {
primary = g_strdup_printf (_("Unable to unmount %p"), source_object);
}
dialog = gtk_message_dialog_new (NULL,
0,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"%s",
primary);
gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
"%s",
error->message);
gtk_widget_show (GTK_WIDGET (dialog));
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
g_free (primary);
}
}
if (error != NULL) {
g_error_free (error);
}
}
示例4: brasero_gio_operation_umount_finish
static void
brasero_gio_operation_umount_finish (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
BraseroGioOperation *op = user_data;
if (!op->loop)
return;
op->result = g_mount_unmount_with_operation_finish (G_MOUNT (source),
result,
&op->error);
BRASERO_MEDIA_LOG ("Umount operation completed (result = %d)", op->result);
if (op->error) {
if (op->error->code == G_IO_ERROR_NOT_MOUNTED) {
/* That can happen sometimes */
g_error_free (op->error);
op->error = NULL;
op->result = TRUE;
}
/* Since there was an error. The "unmounted" signal won't be
* emitted by GVolumeMonitor and therefore we'd get stuck if
* we didn't get out of the loop. */
brasero_gio_operation_end (op);
}
else if (!op->result)
brasero_gio_operation_end (op);
}
示例5: shell_util_get_file_display_name_if_mount
static char *
shell_util_get_file_display_name_if_mount (GFile *file)
{
GFile *compare;
GVolumeMonitor *monitor;
GList *mounts, *l;
char *ret;
ret = NULL;
/* compare with all mounts */
monitor = g_volume_monitor_get ();
mounts = g_volume_monitor_get_mounts (monitor);
for (l = mounts; l != NULL; l = l->next)
{
GMount *mount;
mount = G_MOUNT(l->data);
compare = g_mount_get_root (mount);
if (!ret && g_file_equal (file, compare))
ret = g_mount_get_name (mount);
g_object_unref (mount);
}
g_list_free (mounts);
g_object_unref (monitor);
return ret;
}
示例6: eject_cb
static void
eject_cb (GObject *object, GAsyncResult *result, gpointer nothing)
{
GError *error = NULL;
if (G_IS_VOLUME (object)) {
GVolume *volume = G_VOLUME (object);
rb_debug ("finishing ejection of volume");
g_volume_eject_with_operation_finish (volume, result, &error);
} else if (G_IS_MOUNT (object)) {
GMount *mount = G_MOUNT (object);
rb_debug ("finishing ejection of mount");
g_mount_eject_with_operation_finish (mount, result, &error);
}
if (error != NULL) {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED)) {
rb_error_dialog (NULL, _("Unable to eject"), "%s", error->message);
} else {
rb_debug ("eject failure has already been handled");
}
g_error_free (error);
}
}
示例7: unmount_done_cb
static void
unmount_done_cb (GObject *object, GAsyncResult *result, gpointer psource)
{
GMount *mount;
RBMtpSource *source;
gboolean ok;
GError *error = NULL;
RBMtpSourcePrivate *priv;
mount = G_MOUNT (object);
source = RB_MTP_SOURCE (psource);
priv = MTP_SOURCE_GET_PRIVATE (source);
ok = g_mount_unmount_with_operation_finish (mount, result, &error);
if (ok) {
rb_debug ("successfully unmounted mtp device");
priv->remount_volume = g_mount_get_volume (mount);
open_device (source);
} else {
g_warning ("Unable to unmount MTP device: %s", error->message);
g_error_free (error);
}
g_object_unref (mount);
g_object_unref (source);
}
示例8: bookmark_location_mounted_callback
static gboolean
bookmark_location_mounted_callback (NemoBookmark *bookmark,
GFile *location,
NemoBookmarkList *bookmarks)
{
gboolean ret = FALSE;
GList *volumes = g_volume_monitor_get_mounts (bookmarks->volume_monitor);
GList *iter = volumes;
while (iter != NULL) {
GMount *mount = G_MOUNT (iter->data);
GFile *mount_location = g_mount_get_root (mount);
gchar *mount_root_uri = g_file_get_uri (mount_location);
gchar *location_uri = g_file_get_uri (location);
ret = g_str_has_prefix (location_uri, mount_root_uri);
g_free (mount_root_uri);
g_free (location_uri);
g_object_unref (mount_location);
if (ret == TRUE)
break;
iter = iter->next;
}
g_list_free_full (volumes, (GDestroyNotify) g_object_unref);
return ret;
}
示例9: unmount_all_with_scheme
static void
unmount_all_with_scheme (const char *scheme)
{
GVolumeMonitor *volume_monitor;
GList *mounts;
GList *l;
volume_monitor = g_volume_monitor_get();
/* populate gvfs network mounts */
iterate_gmain();
mounts = g_volume_monitor_get_mounts (volume_monitor);
for (l = mounts; l != NULL; l = l->next) {
GMount *mount = G_MOUNT (l->data);
GFile *root;
root = g_mount_get_root (mount);
if (g_file_has_uri_scheme (root, scheme)) {
unmount (root);
}
g_object_unref (root);
}
g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
g_list_free (mounts);
g_object_unref (volume_monitor);
}
示例10: on_unmounted
static void on_unmounted(GObject* mnt, GAsyncResult* res, gpointer input_data)
{
#define data ((EjectData*)input_data)
GError* err = NULL;
/* FIXME: with this approach, we could have racing condition.
* Someone may mount other volumes before we finishing unmounting them all. */
gboolean success = g_mount_unmount_finish(G_MOUNT(mnt), res, &err);
if(success)
{
if(data->mounts) /* we still have some volumes on this drive mounted */
unmount_before_eject(data);
else /* all unmounted, do the eject. */
do_eject(data);
}
else
{
GSimpleAsyncResult* res;
GError* error = g_udisks_error_to_gio_error(err);
g_error_free(err);
res = g_simple_async_result_new_from_error(G_OBJECT(data->drv),
data->callback,
data->user_data,
err);
finish_eject(res, data);
g_error_free(error);
}
#undef data
}
示例11: find_mount_for_device
static GMount *
find_mount_for_device (GUdevDevice *device)
{
GMount *mount = NULL;
const char *device_file;
GVolumeMonitor *volmon;
GList *mounts;
GList *i;
device_file = g_udev_device_get_device_file (device);
if (device_file == NULL) {
return NULL;
}
volmon = g_volume_monitor_get ();
mounts = g_volume_monitor_get_mounts (volmon);
g_object_unref (volmon);
for (i = mounts; i != NULL; i = i->next) {
GVolume *v;
v = g_mount_get_volume (G_MOUNT (i->data));
if (v != NULL) {
char *devname = NULL;
gboolean match;
devname = g_volume_get_identifier (v, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
g_object_unref (v);
if (devname == NULL)
continue;
match = g_str_equal (devname, device_file);
g_free (devname);
if (match) {
mount = G_MOUNT (i->data);
g_object_ref (G_OBJECT (mount));
break;
}
}
}
g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
g_list_free (mounts);
return mount;
}
示例12: on_content_type_finished
static void on_content_type_finished(GObject* src_obj, GAsyncResult* res, gpointer user_data)
{
AutoRun* data = (AutoRun*)user_data;
GMount* mount = G_MOUNT(src_obj);
char** types;
char* desc = NULL;
types = g_mount_guess_content_type_finish(mount, res, NULL);
if(types)
{
GtkTreeIter it;
GList* apps = NULL, *l;
char** type;
if(types[0])
{
for(type=types;*type;++type)
{
l = g_app_info_get_all_for_type(*type);
if(l)
apps = g_list_concat(apps, l);
}
desc = g_content_type_get_description(types[0]);
}
g_strfreev(types);
if(apps)
{
int pos = 0;
GtkTreePath* tp;
for(l = apps; l; l=l->next, ++pos)
{
GAppInfo* app = G_APP_INFO(l->data);
gtk_list_store_insert_with_values(data->store, &it, pos,
0, g_app_info_get_icon(app),
1, g_app_info_get_name(app),
2, app, -1);
g_object_unref(app);
}
g_list_free(apps);
gtk_tree_model_get_iter_first(GTK_TREE_MODEL(data->store), &it);
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(data->view), &it);
tp = gtk_tree_path_new_first();
gtk_tree_view_set_cursor(data->view, tp, NULL, FALSE);
gtk_tree_path_free(tp);
}
}
if(desc)
{
gtk_label_set_text(data->type, desc);
g_free(desc);
}
else
gtk_label_set_text(data->type, _("Removable Disk"));
}
示例13: autorun_guessed_content_type_callback
static void
autorun_guessed_content_type_callback (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
GError *error;
char **guessed_content_type;
AutorunData *data = user_data;
gboolean open_folder;
open_folder = FALSE;
error = NULL;
guessed_content_type = g_mount_guess_content_type_finish (G_MOUNT (source_object), res, &error);
g_object_set_data_full (source_object,
"caja-content-type-cache",
g_strdupv (guessed_content_type),
(GDestroyNotify)g_strfreev);
if (error != NULL)
{
g_warning ("Unabled to guess content type for mount: %s", error->message);
g_error_free (error);
}
else
{
if (guessed_content_type != NULL && g_strv_length (guessed_content_type) > 0)
{
int n;
for (n = 0; guessed_content_type[n] != NULL; n++)
{
if (do_autorun_for_content_type (data->mount, guessed_content_type[n],
data->open_window_func, data->user_data))
{
open_folder = TRUE;
}
}
g_strfreev (guessed_content_type);
}
else
{
if (g_settings_get_boolean (caja_media_preferences, CAJA_PREFERENCES_MEDIA_AUTOMOUNT_OPEN))
open_folder = TRUE;
}
}
/* only open the folder once.. */
if (open_folder && data->open_window_func != NULL)
{
data->open_window_func (data->mount, data->user_data);
}
g_object_unref (data->mount);
g_free (data);
}
示例14: unmount_before_eject
static void unmount_before_eject(EjectData* data)
{
GMount* mnt = G_MOUNT(data->mounts->data);
data->mounts = g_list_delete_link(data->mounts, data->mounts);
/* pop the first GMount in the list. */
g_mount_unmount_with_operation(mnt, data->flags, data->op,
data->cancellable,
on_unmounted, data);
/* FIXME: Notify volume monitor!! */
g_object_unref(mnt);
}
示例15: eject_done_cb
static void
eject_done_cb (GObject *object,
GAsyncResult *res,
gpointer user_data)
{
gboolean succeeded;
GError *error = NULL;
succeeded = g_mount_eject_with_operation_finish (G_MOUNT (object), res, &error);
g_object_unref (G_MOUNT (object));
if (!succeeded)
g_printerr (_("Error ejecting mount: %s\n"), error->message);
outstanding_mounts--;
if (outstanding_mounts == 0)
g_main_loop_quit (main_loop);
}