inline static gboolean automount_volume(GVolume* vol, gboolean silent) { GMount* mount; if(!g_volume_should_automount(vol) || !g_volume_can_mount(vol)) return FALSE; mount = g_volume_get_mount(vol); if(!mount) /* not mounted, automount is needed */ { g_debug("try automount"); if(!fm_mount_volume(NULL, vol, !silent)) return FALSE; if(silent) return TRUE; mount = g_volume_get_mount(vol); g_debug("mount = %p", mount); } if(mount) { if(!silent && app_config->autorun) /* show autorun dialog */ show_autorun_dlg(vol, mount); g_object_unref(mount); } return TRUE; }
void on_mount(GtkAction* act, gpointer user_data) { PlaceItem* item = (PlaceItem*)user_data; GMount* mnt = g_volume_get_mount(item->vol); if(!mnt) { if(!fm_mount_volume(NULL, item->vol)) return; } else g_object_unref(mnt); }
void activate_row(FmPlacesView* view, guint button, GtkTreePath* tree_path) { GtkTreeIter it; if(gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &it, tree_path)) { FmPlaceItem* item; FmPath* path; gtk_tree_model_get(GTK_TREE_MODEL(model), &it, FM_PLACES_MODEL_COL_INFO, &item, -1); if(!item) return; switch(item->type) { case FM_PLACES_ITEM_PATH: path = fm_path_ref(item->fi->path); break; case FM_PLACES_ITEM_VOL: { GFile* gf; GMount* mnt = g_volume_get_mount(item->vol); if(!mnt) { GtkWindow* parent = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view))); if(!fm_mount_volume(parent, item->vol, TRUE)) return; mnt = g_volume_get_mount(item->vol); if(!mnt) { g_debug("GMount is invalid after successful g_volume_mount().\nThis is quite possibly a gvfs bug.\nSee https://bugzilla.gnome.org/show_bug.cgi?id=552168"); return; } } gf = g_mount_get_root(mnt); g_object_unref(mnt); if(gf) { path = fm_path_new_for_gfile(gf); g_object_unref(gf); } else path = NULL; break; } default: return; } if(path) { g_signal_emit(view, signals[CHDIR], 0, button, path); fm_path_unref(path); } } }
void on_row_activated(GtkTreeView* view, GtkTreePath* tree_path, GtkTreeViewColumn *col) { GtkTreeIter it; if(gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &it, tree_path)) { PlaceItem* item; FmPath* path; gtk_tree_model_get(GTK_TREE_MODEL(model), &it, COL_INFO, &item, -1); if(!item) return; switch(item->type) { case PLACE_PATH: path = fm_path_ref(item->path); break; case PLACE_VOL: { GFile* gf; GMount* mnt = g_volume_get_mount(item->vol); if(!mnt) { if(!fm_mount_volume(NULL, item->vol)) return; mnt = g_volume_get_mount(item->vol); } gf = g_mount_get_root(mnt); g_object_unref(mnt); path = fm_path_new_for_gfile(gf); g_object_unref(gf); break; } default: return; } g_signal_emit(view, signals[CHDIR], 0, path); fm_path_unref(path); } }